diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 489 |
1 files changed, 416 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3ac6327..171443e 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 | { |
@@ -3104,7 +3241,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3104 | // Avatar is already disposed :/ | 3241 | // Avatar is already disposed :/ |
3105 | } | 3242 | } |
3106 | 3243 | ||
3244 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3107 | m_eventManager.TriggerOnRemovePresence(agentID); | 3245 | m_eventManager.TriggerOnRemovePresence(agentID); |
3246 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3247 | |||
3248 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3249 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3108 | 3250 | ||
3109 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3251 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3110 | AttachmentsModule.SaveChangedAttachments(avatar); | 3252 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3124,8 +3266,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3124 | } | 3266 | } |
3125 | 3267 | ||
3126 | // Remove the avatar from the scene | 3268 | // Remove the avatar from the scene |
3269 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3127 | m_sceneGraph.RemoveScenePresence(agentID); | 3270 | m_sceneGraph.RemoveScenePresence(agentID); |
3271 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3128 | m_clientManager.Remove(agentID); | 3272 | m_clientManager.Remove(agentID); |
3273 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3129 | 3274 | ||
3130 | try | 3275 | try |
3131 | { | 3276 | { |
@@ -3139,9 +3284,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3139 | { | 3284 | { |
3140 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3285 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3141 | } | 3286 | } |
3142 | 3287 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3143 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3288 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3144 | // CleanDroppedAttachments(); | 3289 | // CleanDroppedAttachments(); |
3290 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3145 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3291 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3146 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3292 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3147 | } | 3293 | } |
@@ -3260,13 +3406,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3260 | sp = null; | 3406 | sp = null; |
3261 | } | 3407 | } |
3262 | 3408 | ||
3263 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3264 | 3409 | ||
3265 | //On login test land permisions | 3410 | //On login test land permisions |
3266 | if (vialogin) | 3411 | if (vialogin) |
3267 | { | 3412 | { |
3268 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3413 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3414 | if (cache != null) | ||
3415 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3416 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3269 | { | 3417 | { |
3418 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3270 | return false; | 3419 | return false; |
3271 | } | 3420 | } |
3272 | } | 3421 | } |
@@ -3289,8 +3438,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | 3438 | ||
3290 | try | 3439 | try |
3291 | { | 3440 | { |
3292 | if (!AuthorizeUser(agent, out reason)) | 3441 | // Always check estate if this is a login. Always |
3293 | return false; | 3442 | // check if banned regions are to be blacked out. |
3443 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3444 | { | ||
3445 | if (!AuthorizeUser(agent, out reason)) | ||
3446 | return false; | ||
3447 | } | ||
3294 | } | 3448 | } |
3295 | catch (Exception e) | 3449 | catch (Exception e) |
3296 | { | 3450 | { |
@@ -3392,6 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3392 | } | 3546 | } |
3393 | } | 3547 | } |
3394 | // Honor parcel landing type and position. | 3548 | // Honor parcel landing type and position. |
3549 | /* | ||
3550 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3395 | if (land != null) | 3551 | if (land != null) |
3396 | { | 3552 | { |
3397 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3553 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3399,26 +3555,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3399 | agent.startpos = land.LandData.UserLocation; | 3555 | agent.startpos = land.LandData.UserLocation; |
3400 | } | 3556 | } |
3401 | } | 3557 | } |
3558 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3402 | } | 3559 | } |
3403 | 3560 | ||
3404 | return true; | 3561 | return true; |
3405 | } | 3562 | } |
3406 | 3563 | ||
3407 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3564 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3408 | { | 3565 | { |
3409 | 3566 | reason = String.Empty; | |
3410 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3567 | if (Permissions.IsGod(agentID)) |
3411 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3568 | return true; |
3569 | |||
3570 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3571 | if (land == null) | ||
3572 | return false; | ||
3573 | |||
3574 | bool banned = land.IsBannedFromLand(agentID); | ||
3575 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3412 | 3576 | ||
3413 | if (banned || restricted) | 3577 | if (banned || restricted) |
3414 | { | 3578 | { |
3415 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3579 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3416 | if (nearestParcel != null) | 3580 | if (nearestParcel != null) |
3417 | { | 3581 | { |
3418 | //Move agent to nearest allowed | 3582 | //Move agent to nearest allowed |
3419 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3583 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3420 | agent.startpos.X = newPosition.X; | 3584 | posX = newPosition.X; |
3421 | agent.startpos.Y = newPosition.Y; | 3585 | posY = newPosition.Y; |
3422 | } | 3586 | } |
3423 | else | 3587 | else |
3424 | { | 3588 | { |
@@ -3480,7 +3644,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3480 | 3644 | ||
3481 | if (!m_strictAccessControl) return true; | 3645 | if (!m_strictAccessControl) return true; |
3482 | if (Permissions.IsGod(agent.AgentID)) return true; | 3646 | if (Permissions.IsGod(agent.AgentID)) return true; |
3483 | 3647 | ||
3484 | if (AuthorizationService != null) | 3648 | if (AuthorizationService != null) |
3485 | { | 3649 | { |
3486 | if (!AuthorizationService.IsAuthorizedForRegion( | 3650 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3488,14 +3652,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3488 | { | 3652 | { |
3489 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3653 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3490 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3654 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3491 | 3655 | ||
3492 | return false; | 3656 | return false; |
3493 | } | 3657 | } |
3494 | } | 3658 | } |
3495 | 3659 | ||
3496 | if (m_regInfo.EstateSettings != null) | 3660 | if (m_regInfo.EstateSettings != null) |
3497 | { | 3661 | { |
3498 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3662 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3499 | { | 3663 | { |
3500 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3664 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3501 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3665 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3685,6 +3849,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3685 | 3849 | ||
3686 | // We have to wait until the viewer contacts this region after receiving EAC. | 3850 | // We have to wait until the viewer contacts this region after receiving EAC. |
3687 | // That calls AddNewClient, which finally creates the ScenePresence | 3851 | // That calls AddNewClient, which finally creates the ScenePresence |
3852 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3853 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3854 | { | ||
3855 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3856 | return false; | ||
3857 | } | ||
3858 | |||
3688 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3859 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3689 | if (nearestParcel == null) | 3860 | if (nearestParcel == null) |
3690 | { | 3861 | { |
@@ -3766,12 +3937,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3766 | return false; | 3937 | return false; |
3767 | } | 3938 | } |
3768 | 3939 | ||
3940 | public bool IncomingCloseAgent(UUID agentID) | ||
3941 | { | ||
3942 | return IncomingCloseAgent(agentID, false); | ||
3943 | } | ||
3944 | |||
3945 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3946 | { | ||
3947 | return IncomingCloseAgent(agentID, true); | ||
3948 | } | ||
3949 | |||
3769 | /// <summary> | 3950 | /// <summary> |
3770 | /// Tell a single agent to disconnect from the region. | 3951 | /// Tell a single agent to disconnect from the region. |
3771 | /// </summary> | 3952 | /// </summary> |
3772 | /// <param name="regionHandle"></param> | ||
3773 | /// <param name="agentID"></param> | 3953 | /// <param name="agentID"></param> |
3774 | public bool IncomingCloseAgent(UUID agentID) | 3954 | /// <param name="childOnly"></param> |
3955 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3775 | { | 3956 | { |
3776 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3957 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3777 | 3958 | ||
@@ -3783,7 +3964,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3783 | { | 3964 | { |
3784 | m_sceneGraph.removeUserCount(false); | 3965 | m_sceneGraph.removeUserCount(false); |
3785 | } | 3966 | } |
3786 | else | 3967 | else if (!childOnly) |
3787 | { | 3968 | { |
3788 | m_sceneGraph.removeUserCount(true); | 3969 | m_sceneGraph.removeUserCount(true); |
3789 | } | 3970 | } |
@@ -3799,9 +3980,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3799 | } | 3980 | } |
3800 | else | 3981 | else |
3801 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3982 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3983 | presence.ControllingClient.Close(false); | ||
3984 | } | ||
3985 | else if (!childOnly) | ||
3986 | { | ||
3987 | presence.ControllingClient.Close(true); | ||
3802 | } | 3988 | } |
3803 | |||
3804 | presence.ControllingClient.Close(); | ||
3805 | return true; | 3989 | return true; |
3806 | } | 3990 | } |
3807 | 3991 | ||
@@ -4396,34 +4580,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4396 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4580 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4397 | } | 4581 | } |
4398 | 4582 | ||
4399 | public int GetHealth() | 4583 | public int GetHealth(out int flags, out string message) |
4400 | { | 4584 | { |
4401 | // Returns: | 4585 | // Returns: |
4402 | // 1 = sim is up and accepting http requests. The heartbeat has | 4586 | // 1 = sim is up and accepting http requests. The heartbeat has |
4403 | // stopped and the sim is probably locked up, but a remote | 4587 | // stopped and the sim is probably locked up, but a remote |
4404 | // admin restart may succeed | 4588 | // admin restart may succeed |
4405 | // | 4589 | // |
4406 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4590 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4407 | // usable for people within and logins _may_ work | 4591 | // usable for people within |
4592 | // | ||
4593 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4594 | // unstable and will not accept new logins | ||
4595 | // | ||
4596 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4597 | // likely usable | ||
4408 | // | 4598 | // |
4409 | // 3 = We have seen a new user enter within the past 4 minutes | 4599 | // 5 = We have seen a new user enter within the past 4 minutes |
4410 | // which can be seen as positive confirmation of sim health | 4600 | // which can be seen as positive confirmation of sim health |
4411 | // | 4601 | // |
4602 | |||
4603 | flags = 0; | ||
4604 | message = String.Empty; | ||
4605 | |||
4606 | CheckHeartbeat(); | ||
4607 | |||
4608 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4609 | { | ||
4610 | // We're still starting | ||
4611 | // 0 means "in startup", it can't happen another way, since | ||
4612 | // to get here, we must be able to accept http connections | ||
4613 | return 0; | ||
4614 | } | ||
4615 | |||
4412 | int health=1; // Start at 1, means we're up | 4616 | int health=1; // Start at 1, means we're up |
4413 | 4617 | ||
4414 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4618 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4619 | { | ||
4415 | health+=1; | 4620 | health+=1; |
4416 | else | 4621 | flags |= 1; |
4622 | } | ||
4623 | |||
4624 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4625 | { | ||
4626 | health+=1; | ||
4627 | flags |= 2; | ||
4628 | } | ||
4629 | |||
4630 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4631 | { | ||
4632 | health+=1; | ||
4633 | flags |= 4; | ||
4634 | } | ||
4635 | |||
4636 | if (flags != 7) | ||
4417 | return health; | 4637 | return health; |
4418 | 4638 | ||
4419 | // A login in the last 4 mins? We can't be doing too badly | 4639 | // A login in the last 4 mins? We can't be doing too badly |
4420 | // | 4640 | // |
4421 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4641 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4422 | health++; | 4642 | health++; |
4423 | else | ||
4424 | return health; | ||
4425 | |||
4426 | CheckHeartbeat(); | ||
4427 | 4643 | ||
4428 | return health; | 4644 | return health; |
4429 | } | 4645 | } |
@@ -4616,7 +4832,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4616 | if (m_firstHeartbeat) | 4832 | if (m_firstHeartbeat) |
4617 | return; | 4833 | return; |
4618 | 4834 | ||
4619 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4835 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4620 | StartTimer(); | 4836 | StartTimer(); |
4621 | } | 4837 | } |
4622 | 4838 | ||
@@ -5026,6 +5242,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
5026 | mapModule.GenerateMaptile(); | 5242 | mapModule.GenerateMaptile(); |
5027 | } | 5243 | } |
5028 | 5244 | ||
5245 | // public void CleanDroppedAttachments() | ||
5246 | // { | ||
5247 | // List<SceneObjectGroup> objectsToDelete = | ||
5248 | // new List<SceneObjectGroup>(); | ||
5249 | // | ||
5250 | // lock (m_cleaningAttachments) | ||
5251 | // { | ||
5252 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5253 | // { | ||
5254 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5255 | // { | ||
5256 | // UUID agentID = grp.OwnerID; | ||
5257 | // if (agentID == UUID.Zero) | ||
5258 | // { | ||
5259 | // objectsToDelete.Add(grp); | ||
5260 | // return; | ||
5261 | // } | ||
5262 | // | ||
5263 | // ScenePresence sp = GetScenePresence(agentID); | ||
5264 | // if (sp == null) | ||
5265 | // { | ||
5266 | // objectsToDelete.Add(grp); | ||
5267 | // return; | ||
5268 | // } | ||
5269 | // } | ||
5270 | // }); | ||
5271 | // } | ||
5272 | // | ||
5273 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5274 | // { | ||
5275 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5276 | // DeleteSceneObject(grp, true); | ||
5277 | // } | ||
5278 | // } | ||
5279 | |||
5280 | public void ThreadAlive(int threadCode) | ||
5281 | { | ||
5282 | switch(threadCode) | ||
5283 | { | ||
5284 | case 1: // Incoming | ||
5285 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5286 | break; | ||
5287 | case 2: // Incoming | ||
5288 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5289 | break; | ||
5290 | } | ||
5291 | } | ||
5292 | |||
5029 | // This method is called across the simulation connector to | 5293 | // This method is called across the simulation connector to |
5030 | // determine if a given agent is allowed in this region | 5294 | // determine if a given agent is allowed in this region |
5031 | // AS A ROOT AGENT. Returning false here will prevent them | 5295 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5034,6 +5298,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5034 | // child agent creation, thereby emulating the SL behavior. | 5298 | // child agent creation, thereby emulating the SL behavior. |
5035 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5299 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5036 | { | 5300 | { |
5301 | reason = "You are banned from the region"; | ||
5302 | |||
5303 | if (Permissions.IsGod(agentID)) | ||
5304 | { | ||
5305 | reason = String.Empty; | ||
5306 | return true; | ||
5307 | } | ||
5308 | |||
5037 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5309 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5038 | 5310 | ||
5039 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5311 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5045,11 +5317,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5045 | } | 5317 | } |
5046 | } | 5318 | } |
5047 | 5319 | ||
5320 | ScenePresence presence = GetScenePresence(agentID); | ||
5321 | IClientAPI client = null; | ||
5322 | AgentCircuitData aCircuit = null; | ||
5323 | |||
5324 | if (presence != null) | ||
5325 | { | ||
5326 | client = presence.ControllingClient; | ||
5327 | if (client != null) | ||
5328 | aCircuit = client.RequestClientInfo(); | ||
5329 | } | ||
5330 | |||
5331 | // We may be called before there is a presence or a client. | ||
5332 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5333 | if (client == null) | ||
5334 | { | ||
5335 | aCircuit = new AgentCircuitData(); | ||
5336 | aCircuit.AgentID = agentID; | ||
5337 | aCircuit.firstname = String.Empty; | ||
5338 | aCircuit.lastname = String.Empty; | ||
5339 | } | ||
5340 | |||
5341 | try | ||
5342 | { | ||
5343 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5344 | { | ||
5345 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5346 | return false; | ||
5347 | } | ||
5348 | } | ||
5349 | catch (Exception e) | ||
5350 | { | ||
5351 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5352 | return false; | ||
5353 | } | ||
5354 | |||
5355 | if (position == Vector3.Zero) // Teleport | ||
5356 | { | ||
5357 | float posX = 128.0f; | ||
5358 | float posY = 128.0f; | ||
5359 | |||
5360 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5361 | { | ||
5362 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5363 | return false; | ||
5364 | } | ||
5365 | } | ||
5366 | else // Walking | ||
5367 | { | ||
5368 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5369 | if (land == null) | ||
5370 | return false; | ||
5371 | |||
5372 | bool banned = land.IsBannedFromLand(agentID); | ||
5373 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5374 | |||
5375 | if (banned || restricted) | ||
5376 | return false; | ||
5377 | } | ||
5378 | |||
5048 | reason = String.Empty; | 5379 | reason = String.Empty; |
5049 | return true; | 5380 | return true; |
5050 | } | 5381 | } |
5051 | 5382 | ||
5052 | /// <summary> | 5383 | public void StartTimerWatchdog() |
5384 | { | ||
5385 | m_timerWatchdog.Interval = 1000; | ||
5386 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5387 | m_timerWatchdog.AutoReset = true; | ||
5388 | m_timerWatchdog.Start(); | ||
5389 | } | ||
5390 | |||
5391 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5392 | { | ||
5393 | CheckHeartbeat(); | ||
5394 | } | ||
5395 | |||
5053 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5396 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5054 | /// autopilot that moves an avatar to a sit target!. | 5397 | /// autopilot that moves an avatar to a sit target!. |
5055 | /// </summary> | 5398 | /// </summary> |