diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 504 |
1 files changed, 418 insertions, 86 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0832975..1a3e3bb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -96,6 +96,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
96 | // TODO: need to figure out how allow client agents but deny | 96 | // TODO: need to figure out how allow client agents but deny |
97 | // root agents when ACL denies access to root agent | 97 | // root agents when ACL denies access to root agent |
98 | public bool m_strictAccessControl = true; | 98 | public bool m_strictAccessControl = true; |
99 | public bool m_seeIntoBannedRegion = false; | ||
99 | public int MaxUndoCount = 5; | 100 | public int MaxUndoCount = 5; |
100 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 101 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
101 | public bool LoginLock = false; | 102 | public bool LoginLock = false; |
@@ -111,12 +112,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
111 | 112 | ||
112 | protected int m_splitRegionID; | 113 | protected int m_splitRegionID; |
113 | protected Timer m_restartWaitTimer = new Timer(); | 114 | protected Timer m_restartWaitTimer = new Timer(); |
115 | protected Timer m_timerWatchdog = new Timer(); | ||
114 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 116 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
115 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 117 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
116 | protected string m_simulatorVersion = "OpenSimulator Server"; | 118 | protected string m_simulatorVersion = "OpenSimulator Server"; |
117 | protected ModuleLoader m_moduleLoader; | 119 | protected ModuleLoader m_moduleLoader; |
118 | protected AgentCircuitManager m_authenticateHandler; | 120 | protected AgentCircuitManager m_authenticateHandler; |
119 | protected SceneCommunicationService m_sceneGridService; | 121 | protected SceneCommunicationService m_sceneGridService; |
122 | protected ISnmpModule m_snmpService = null; | ||
120 | 123 | ||
121 | protected ISimulationDataService m_SimulationDataService; | 124 | protected ISimulationDataService m_SimulationDataService; |
122 | protected IEstateDataService m_EstateDataService; | 125 | protected IEstateDataService m_EstateDataService; |
@@ -168,7 +171,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | private int m_update_events = 1; | 171 | private int m_update_events = 1; |
169 | private int m_update_backup = 200; | 172 | private int m_update_backup = 200; |
170 | private int m_update_terrain = 50; | 173 | private int m_update_terrain = 50; |
171 | // private int m_update_land = 1; | 174 | private int m_update_land = 10; |
172 | private int m_update_coarse_locations = 50; | 175 | private int m_update_coarse_locations = 50; |
173 | 176 | ||
174 | private int agentMS; | 177 | private int agentMS; |
@@ -183,6 +186,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
183 | private int landMS; | 186 | private int landMS; |
184 | private int lastCompletedFrame; | 187 | private int lastCompletedFrame; |
185 | 188 | ||
189 | public bool CombineRegions = false; | ||
186 | /// <summary> | 190 | /// <summary> |
187 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 191 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
188 | /// asynchronously from the update loop. | 192 | /// asynchronously from the update loop. |
@@ -205,10 +209,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
205 | private bool m_scripts_enabled = true; | 209 | private bool m_scripts_enabled = true; |
206 | private string m_defaultScriptEngine; | 210 | private string m_defaultScriptEngine; |
207 | private int m_LastLogin; | 211 | private int m_LastLogin; |
208 | private Thread HeartbeatThread; | 212 | private Thread HeartbeatThread = null; |
209 | private volatile bool shuttingdown; | 213 | private volatile bool shuttingdown; |
210 | 214 | ||
211 | private int m_lastUpdate; | 215 | private int m_lastUpdate; |
216 | private int m_lastIncoming; | ||
217 | private int m_lastOutgoing; | ||
212 | private bool m_firstHeartbeat = true; | 218 | private bool m_firstHeartbeat = true; |
213 | 219 | ||
214 | private object m_deleting_scene_object = new object(); | 220 | private object m_deleting_scene_object = new object(); |
@@ -256,6 +262,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
256 | get { return m_sceneGridService; } | 262 | get { return m_sceneGridService; } |
257 | } | 263 | } |
258 | 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 | |||
259 | public ISimulationDataService SimulationDataService | 278 | public ISimulationDataService SimulationDataService |
260 | { | 279 | { |
261 | get | 280 | get |
@@ -537,6 +556,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
537 | m_EstateDataService = estateDataService; | 556 | m_EstateDataService = estateDataService; |
538 | m_regionHandle = m_regInfo.RegionHandle; | 557 | m_regionHandle = m_regInfo.RegionHandle; |
539 | m_regionName = m_regInfo.RegionName; | 558 | m_regionName = m_regInfo.RegionName; |
559 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
560 | m_lastIncoming = 0; | ||
561 | m_lastOutgoing = 0; | ||
540 | 562 | ||
541 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 563 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
542 | m_asyncSceneObjectDeleter.Enabled = true; | 564 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -650,11 +672,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
650 | //Animation states | 672 | //Animation states |
651 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 673 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
652 | // TODO: Change default to true once the feature is supported | 674 | // TODO: Change default to true once the feature is supported |
653 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 675 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
654 | 676 | ||
655 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); | 677 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); |
656 | 678 | ||
657 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 679 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
680 | |||
681 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
658 | if (RegionInfo.NonphysPrimMax > 0) | 682 | if (RegionInfo.NonphysPrimMax > 0) |
659 | { | 683 | { |
660 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 684 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -686,6 +710,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
686 | m_persistAfter *= 10000000; | 710 | m_persistAfter *= 10000000; |
687 | 711 | ||
688 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 712 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
713 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
689 | 714 | ||
690 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 715 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
691 | if (packetConfig != null) | 716 | if (packetConfig != null) |
@@ -695,6 +720,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
695 | } | 720 | } |
696 | 721 | ||
697 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 722 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
723 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
724 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
698 | 725 | ||
699 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 726 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
700 | if (m_generateMaptiles) | 727 | if (m_generateMaptiles) |
@@ -730,9 +757,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
730 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 757 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
731 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 758 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
732 | } | 759 | } |
733 | catch | 760 | catch (Exception e) |
734 | { | 761 | { |
735 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 762 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
736 | } | 763 | } |
737 | 764 | ||
738 | #endregion Region Config | 765 | #endregion Region Config |
@@ -1143,7 +1170,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1143 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1170 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1144 | if (HeartbeatThread != null) | 1171 | if (HeartbeatThread != null) |
1145 | { | 1172 | { |
1173 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1146 | HeartbeatThread.Abort(); | 1174 | HeartbeatThread.Abort(); |
1175 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1147 | HeartbeatThread = null; | 1176 | HeartbeatThread = null; |
1148 | } | 1177 | } |
1149 | m_lastUpdate = Util.EnvironmentTickCount(); | 1178 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1186,9 +1215,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1186 | { | 1215 | { |
1187 | while (!shuttingdown) | 1216 | while (!shuttingdown) |
1188 | Update(); | 1217 | Update(); |
1189 | |||
1190 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1191 | m_firstHeartbeat = false; | ||
1192 | } | 1218 | } |
1193 | catch (ThreadAbortException) | 1219 | catch (ThreadAbortException) |
1194 | { | 1220 | { |
@@ -1286,6 +1312,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1286 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1312 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1287 | } | 1313 | } |
1288 | 1314 | ||
1315 | // if (Frame % m_update_land == 0) | ||
1316 | // { | ||
1317 | // int ldMS = Util.EnvironmentTickCount(); | ||
1318 | // UpdateLand(); | ||
1319 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1320 | // } | ||
1321 | |||
1289 | if (Frame % m_update_backup == 0) | 1322 | if (Frame % m_update_backup == 0) |
1290 | { | 1323 | { |
1291 | int backMS = Util.EnvironmentTickCount(); | 1324 | int backMS = Util.EnvironmentTickCount(); |
@@ -1387,12 +1420,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1387 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1420 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1388 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1421 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1389 | 1422 | ||
1423 | |||
1424 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1425 | m_firstHeartbeat = false; | ||
1426 | |||
1390 | if (maintc > 0) | 1427 | if (maintc > 0) |
1391 | Thread.Sleep(maintc); | 1428 | Thread.Sleep(maintc); |
1392 | 1429 | ||
1393 | // Tell the watchdog that this thread is still alive | 1430 | // Tell the watchdog that this thread is still alive |
1394 | Watchdog.UpdateThread(); | 1431 | Watchdog.UpdateThread(); |
1395 | } | 1432 | } |
1396 | 1433 | ||
1397 | public void AddGroupTarget(SceneObjectGroup grp) | 1434 | public void AddGroupTarget(SceneObjectGroup grp) |
1398 | { | 1435 | { |
@@ -1408,9 +1445,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1408 | 1445 | ||
1409 | private void CheckAtTargets() | 1446 | private void CheckAtTargets() |
1410 | { | 1447 | { |
1411 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1448 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1412 | lock (m_groupsWithTargets) | 1449 | lock (m_groupsWithTargets) |
1413 | objs = m_groupsWithTargets.Values; | 1450 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1414 | 1451 | ||
1415 | foreach (SceneObjectGroup entry in objs) | 1452 | foreach (SceneObjectGroup entry in objs) |
1416 | entry.checkAtTargets(); | 1453 | entry.checkAtTargets(); |
@@ -1492,7 +1529,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1492 | msg.fromAgentName = "Server"; | 1529 | msg.fromAgentName = "Server"; |
1493 | msg.dialog = (byte)19; // Object msg | 1530 | msg.dialog = (byte)19; // Object msg |
1494 | msg.fromGroup = false; | 1531 | msg.fromGroup = false; |
1495 | msg.offline = (byte)0; | 1532 | msg.offline = (byte)1; |
1496 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1533 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1497 | msg.Position = Vector3.Zero; | 1534 | msg.Position = Vector3.Zero; |
1498 | msg.RegionID = RegionInfo.RegionID.Guid; | 1535 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1727,14 +1764,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1727 | /// <returns></returns> | 1764 | /// <returns></returns> |
1728 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1765 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1729 | { | 1766 | { |
1767 | |||
1768 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1769 | Vector3 wpos = Vector3.Zero; | ||
1770 | // Check for water surface intersection from above | ||
1771 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1772 | { | ||
1773 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1774 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1775 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1776 | wpos.Z = wheight; | ||
1777 | } | ||
1778 | |||
1730 | Vector3 pos = Vector3.Zero; | 1779 | Vector3 pos = Vector3.Zero; |
1731 | if (RayEndIsIntersection == (byte)1) | 1780 | if (RayEndIsIntersection == (byte)1) |
1732 | { | 1781 | { |
1733 | pos = RayEnd; | 1782 | pos = RayEnd; |
1734 | return pos; | ||
1735 | } | 1783 | } |
1736 | 1784 | else if (RayTargetID != UUID.Zero) | |
1737 | if (RayTargetID != UUID.Zero) | ||
1738 | { | 1785 | { |
1739 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1786 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1740 | 1787 | ||
@@ -1756,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1756 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1803 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1757 | 1804 | ||
1758 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1805 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1759 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1806 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1760 | float ScaleOffset = 0.5f; | 1807 | float ScaleOffset = 0.5f; |
1761 | 1808 | ||
1762 | // If we hit something | 1809 | // If we hit something |
@@ -1779,13 +1826,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1779 | //pos.Z -= 0.25F; | 1826 | //pos.Z -= 0.25F; |
1780 | 1827 | ||
1781 | } | 1828 | } |
1782 | |||
1783 | return pos; | ||
1784 | } | 1829 | } |
1785 | else | 1830 | else |
1786 | { | 1831 | { |
1787 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1832 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1788 | |||
1789 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1833 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1790 | 1834 | ||
1791 | // Un-comment the following line to print the raytrace results to the console. | 1835 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1794,13 +1838,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1794 | if (ei.HitTF) | 1838 | if (ei.HitTF) |
1795 | { | 1839 | { |
1796 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1840 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1797 | } else | 1841 | } |
1842 | else | ||
1798 | { | 1843 | { |
1799 | // fall back to our stupid functionality | 1844 | // fall back to our stupid functionality |
1800 | pos = RayEnd; | 1845 | pos = RayEnd; |
1801 | } | 1846 | } |
1802 | |||
1803 | return pos; | ||
1804 | } | 1847 | } |
1805 | } | 1848 | } |
1806 | else | 1849 | else |
@@ -1811,8 +1854,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1811 | //increase height so its above the ground. | 1854 | //increase height so its above the ground. |
1812 | //should be getting the normal of the ground at the rez point and using that? | 1855 | //should be getting the normal of the ground at the rez point and using that? |
1813 | pos.Z += scale.Z / 2f; | 1856 | pos.Z += scale.Z / 2f; |
1814 | return pos; | 1857 | // return pos; |
1815 | } | 1858 | } |
1859 | |||
1860 | // check against posible water intercept | ||
1861 | if (wpos.Z > pos.Z) pos = wpos; | ||
1862 | return pos; | ||
1816 | } | 1863 | } |
1817 | 1864 | ||
1818 | 1865 | ||
@@ -1896,7 +1943,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1896 | public bool AddRestoredSceneObject( | 1943 | public bool AddRestoredSceneObject( |
1897 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1944 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1898 | { | 1945 | { |
1899 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1946 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1947 | if (result) | ||
1948 | sceneObject.IsDeleted = false; | ||
1949 | return result; | ||
1900 | } | 1950 | } |
1901 | 1951 | ||
1902 | /// <summary> | 1952 | /// <summary> |
@@ -1986,6 +2036,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1986 | /// </summary> | 2036 | /// </summary> |
1987 | public void DeleteAllSceneObjects() | 2037 | public void DeleteAllSceneObjects() |
1988 | { | 2038 | { |
2039 | DeleteAllSceneObjects(false); | ||
2040 | } | ||
2041 | |||
2042 | /// <summary> | ||
2043 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2044 | /// </summary> | ||
2045 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2046 | { | ||
2047 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1989 | lock (Entities) | 2048 | lock (Entities) |
1990 | { | 2049 | { |
1991 | EntityBase[] entities = Entities.GetEntities(); | 2050 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1994,11 +2053,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1994 | if (e is SceneObjectGroup) | 2053 | if (e is SceneObjectGroup) |
1995 | { | 2054 | { |
1996 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2055 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1997 | if (!sog.IsAttachment) | 2056 | if (sog != null && !sog.IsAttachment) |
1998 | DeleteSceneObject((SceneObjectGroup)e, false); | 2057 | { |
2058 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2059 | { | ||
2060 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2061 | } | ||
2062 | else | ||
2063 | { | ||
2064 | toReturn.Add((SceneObjectGroup)e); | ||
2065 | } | ||
2066 | } | ||
1999 | } | 2067 | } |
2000 | } | 2068 | } |
2001 | } | 2069 | } |
2070 | if (toReturn.Count > 0) | ||
2071 | { | ||
2072 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2073 | } | ||
2002 | } | 2074 | } |
2003 | 2075 | ||
2004 | /// <summary> | 2076 | /// <summary> |
@@ -2046,6 +2118,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2046 | } | 2118 | } |
2047 | 2119 | ||
2048 | group.DeleteGroupFromScene(silent); | 2120 | group.DeleteGroupFromScene(silent); |
2121 | if (!silent) | ||
2122 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2049 | 2123 | ||
2050 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2124 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2051 | } | 2125 | } |
@@ -2400,10 +2474,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2400 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2474 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2401 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2475 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2402 | { | 2476 | { |
2477 | if (sceneObject.OwnerID == UUID.Zero) | ||
2478 | { | ||
2479 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2480 | return false; | ||
2481 | } | ||
2482 | |||
2403 | // If the user is banned, we won't let any of their objects | 2483 | // If the user is banned, we won't let any of their objects |
2404 | // enter. Period. | 2484 | // enter. Period. |
2405 | // | 2485 | // |
2406 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2486 | int flags = GetUserFlags(sceneObject.OwnerID); |
2487 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2407 | { | 2488 | { |
2408 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2489 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2409 | "banned avatar"); | 2490 | "banned avatar"); |
@@ -2450,12 +2531,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2450 | } | 2531 | } |
2451 | else | 2532 | else |
2452 | { | 2533 | { |
2534 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2453 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2535 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2454 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2536 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2455 | } | 2537 | } |
2538 | if (sceneObject.OwnerID == UUID.Zero) | ||
2539 | { | ||
2540 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2541 | return false; | ||
2542 | } | ||
2456 | } | 2543 | } |
2457 | else | 2544 | else |
2458 | { | 2545 | { |
2546 | if (sceneObject.OwnerID == UUID.Zero) | ||
2547 | { | ||
2548 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2549 | return false; | ||
2550 | } | ||
2459 | AddRestoredSceneObject(sceneObject, true, false); | 2551 | AddRestoredSceneObject(sceneObject, true, false); |
2460 | 2552 | ||
2461 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2553 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2485,6 +2577,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2485 | return 2; // StateSource.PrimCrossing | 2577 | return 2; // StateSource.PrimCrossing |
2486 | } | 2578 | } |
2487 | 2579 | ||
2580 | public int GetUserFlags(UUID user) | ||
2581 | { | ||
2582 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2583 | /* | ||
2584 | ScenePresence sp; | ||
2585 | if (TryGetScenePresence(user, out sp)) | ||
2586 | { | ||
2587 | return sp.UserFlags; | ||
2588 | } | ||
2589 | else | ||
2590 | { | ||
2591 | */ | ||
2592 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2593 | if (uac == null) | ||
2594 | return 0; | ||
2595 | return uac.UserFlags; | ||
2596 | //} | ||
2597 | } | ||
2488 | #endregion | 2598 | #endregion |
2489 | 2599 | ||
2490 | #region Add/Remove Avatar Methods | 2600 | #region Add/Remove Avatar Methods |
@@ -2506,6 +2616,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2506 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2616 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2507 | 2617 | ||
2508 | CheckHeartbeat(); | 2618 | CheckHeartbeat(); |
2619 | ScenePresence presence; | ||
2509 | 2620 | ||
2510 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2621 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2511 | { | 2622 | { |
@@ -2541,7 +2652,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2541 | 2652 | ||
2542 | EventManager.TriggerOnNewClient(client); | 2653 | EventManager.TriggerOnNewClient(client); |
2543 | if (vialogin) | 2654 | if (vialogin) |
2655 | { | ||
2544 | EventManager.TriggerOnClientLogin(client); | 2656 | EventManager.TriggerOnClientLogin(client); |
2657 | |||
2658 | // Send initial parcel data | ||
2659 | Vector3 pos = createdSp.AbsolutePosition; | ||
2660 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2661 | land.SendLandUpdateToClient(client); | ||
2662 | } | ||
2545 | } | 2663 | } |
2546 | } | 2664 | } |
2547 | 2665 | ||
@@ -2630,19 +2748,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2630 | // and the scene presence and the client, if they exist | 2748 | // and the scene presence and the client, if they exist |
2631 | try | 2749 | try |
2632 | { | 2750 | { |
2633 | // We need to wait for the client to make UDP contact first. | 2751 | ScenePresence sp = GetScenePresence(agentID); |
2634 | // It's the UDP contact that creates the scene presence | 2752 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2635 | ScenePresence sp = WaitGetScenePresence(agentID); | 2753 | |
2636 | if (sp != null) | 2754 | if (sp != null) |
2637 | { | ||
2638 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2639 | |||
2640 | sp.ControllingClient.Close(); | 2755 | sp.ControllingClient.Close(); |
2641 | } | 2756 | |
2642 | else | ||
2643 | { | ||
2644 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2645 | } | ||
2646 | // BANG! SLASH! | 2757 | // BANG! SLASH! |
2647 | m_authenticateHandler.RemoveCircuit(agentID); | 2758 | m_authenticateHandler.RemoveCircuit(agentID); |
2648 | 2759 | ||
@@ -2742,6 +2853,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2742 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2853 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2743 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2854 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2744 | client.OnCopyInventoryItem += CopyInventoryItem; | 2855 | client.OnCopyInventoryItem += CopyInventoryItem; |
2856 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2745 | client.OnMoveInventoryItem += MoveInventoryItem; | 2857 | client.OnMoveInventoryItem += MoveInventoryItem; |
2746 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2858 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2747 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2859 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2919,15 +3031,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2919 | /// </summary> | 3031 | /// </summary> |
2920 | /// <param name="agentId">The avatar's Unique ID</param> | 3032 | /// <param name="agentId">The avatar's Unique ID</param> |
2921 | /// <param name="client">The IClientAPI for the client</param> | 3033 | /// <param name="client">The IClientAPI for the client</param> |
2922 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3034 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2923 | { | 3035 | { |
2924 | if (m_teleportModule != null) | 3036 | if (m_teleportModule != null) |
2925 | m_teleportModule.TeleportHome(agentId, client); | 3037 | return m_teleportModule.TeleportHome(agentId, client); |
2926 | else | 3038 | else |
2927 | { | 3039 | { |
2928 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3040 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2929 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3041 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2930 | } | 3042 | } |
3043 | return false; | ||
2931 | } | 3044 | } |
2932 | 3045 | ||
2933 | /// <summary> | 3046 | /// <summary> |
@@ -3019,6 +3132,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3019 | /// <param name="flags"></param> | 3132 | /// <param name="flags"></param> |
3020 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3133 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3021 | { | 3134 | { |
3135 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3136 | ScenePresence presence; | ||
3137 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3138 | { | ||
3139 | if (presence.Appearance != null) | ||
3140 | { | ||
3141 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3142 | } | ||
3143 | } | ||
3144 | |||
3022 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3145 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3023 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3146 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3024 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3147 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3087,8 +3210,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3087 | regions.Remove(RegionInfo.RegionHandle); | 3210 | regions.Remove(RegionInfo.RegionHandle); |
3088 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3211 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3089 | } | 3212 | } |
3090 | 3213 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3091 | m_eventManager.TriggerClientClosed(agentID, this); | 3214 | m_eventManager.TriggerClientClosed(agentID, this); |
3215 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3092 | } | 3216 | } |
3093 | catch (NullReferenceException) | 3217 | catch (NullReferenceException) |
3094 | { | 3218 | { |
@@ -3096,7 +3220,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3096 | // Avatar is already disposed :/ | 3220 | // Avatar is already disposed :/ |
3097 | } | 3221 | } |
3098 | 3222 | ||
3223 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3099 | m_eventManager.TriggerOnRemovePresence(agentID); | 3224 | m_eventManager.TriggerOnRemovePresence(agentID); |
3225 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3226 | |||
3227 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3228 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3100 | 3229 | ||
3101 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3230 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3102 | AttachmentsModule.SaveChangedAttachments(avatar); | 3231 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3105,7 +3234,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3105 | delegate(IClientAPI client) | 3234 | delegate(IClientAPI client) |
3106 | { | 3235 | { |
3107 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3236 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3108 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3237 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3109 | catch (NullReferenceException) { } | 3238 | catch (NullReferenceException) { } |
3110 | }); | 3239 | }); |
3111 | 3240 | ||
@@ -3116,8 +3245,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3116 | } | 3245 | } |
3117 | 3246 | ||
3118 | // Remove the avatar from the scene | 3247 | // Remove the avatar from the scene |
3248 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3119 | m_sceneGraph.RemoveScenePresence(agentID); | 3249 | m_sceneGraph.RemoveScenePresence(agentID); |
3250 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3120 | m_clientManager.Remove(agentID); | 3251 | m_clientManager.Remove(agentID); |
3252 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3121 | 3253 | ||
3122 | try | 3254 | try |
3123 | { | 3255 | { |
@@ -3131,9 +3263,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3131 | { | 3263 | { |
3132 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3264 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3133 | } | 3265 | } |
3134 | 3266 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3135 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3267 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3136 | // CleanDroppedAttachments(); | 3268 | // CleanDroppedAttachments(); |
3269 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3137 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3270 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3138 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3271 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3139 | } | 3272 | } |
@@ -3164,19 +3297,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3164 | 3297 | ||
3165 | #region Entities | 3298 | #region Entities |
3166 | 3299 | ||
3167 | public void SendKillObject(uint localID) | 3300 | public void SendKillObject(List<uint> localIDs) |
3168 | { | 3301 | { |
3169 | SceneObjectPart part = GetSceneObjectPart(localID); | 3302 | List<uint> deleteIDs = new List<uint>(); |
3170 | if (part != null) // It is a prim | 3303 | |
3304 | foreach (uint localID in localIDs) | ||
3171 | { | 3305 | { |
3172 | if (!part.ParentGroup.IsDeleted) // Valid | 3306 | SceneObjectPart part = GetSceneObjectPart(localID); |
3307 | if (part != null) // It is a prim | ||
3173 | { | 3308 | { |
3174 | if (part.ParentGroup.RootPart != part) // Child part | 3309 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3175 | return; | 3310 | { |
3311 | if (part.ParentGroup.RootPart != part) // Child part | ||
3312 | continue; | ||
3313 | } | ||
3176 | } | 3314 | } |
3315 | deleteIDs.Add(localID); | ||
3177 | } | 3316 | } |
3178 | 3317 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3179 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3180 | } | 3318 | } |
3181 | 3319 | ||
3182 | #endregion | 3320 | #endregion |
@@ -3194,7 +3332,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3194 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3332 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3195 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3333 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3196 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3334 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3197 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3198 | m_sceneGridService.OnGetLandData += GetLandData; | 3335 | m_sceneGridService.OnGetLandData += GetLandData; |
3199 | } | 3336 | } |
3200 | 3337 | ||
@@ -3203,7 +3340,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3203 | /// </summary> | 3340 | /// </summary> |
3204 | public void UnRegisterRegionWithComms() | 3341 | public void UnRegisterRegionWithComms() |
3205 | { | 3342 | { |
3206 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3207 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3343 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3208 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3344 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3209 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3345 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3283,13 +3419,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3283 | sp = null; | 3419 | sp = null; |
3284 | } | 3420 | } |
3285 | 3421 | ||
3286 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3287 | 3422 | ||
3288 | //On login test land permisions | 3423 | //On login test land permisions |
3289 | if (vialogin) | 3424 | if (vialogin) |
3290 | { | 3425 | { |
3291 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3426 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3427 | if (cache != null) | ||
3428 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3429 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3292 | { | 3430 | { |
3431 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3293 | return false; | 3432 | return false; |
3294 | } | 3433 | } |
3295 | } | 3434 | } |
@@ -3312,8 +3451,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3312 | 3451 | ||
3313 | try | 3452 | try |
3314 | { | 3453 | { |
3315 | if (!AuthorizeUser(agent, out reason)) | 3454 | // Always check estate if this is a login. Always |
3316 | return false; | 3455 | // check if banned regions are to be blacked out. |
3456 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3457 | { | ||
3458 | if (!AuthorizeUser(agent, out reason)) | ||
3459 | return false; | ||
3460 | } | ||
3317 | } | 3461 | } |
3318 | catch (Exception e) | 3462 | catch (Exception e) |
3319 | { | 3463 | { |
@@ -3415,6 +3559,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3415 | } | 3559 | } |
3416 | } | 3560 | } |
3417 | // Honor parcel landing type and position. | 3561 | // Honor parcel landing type and position. |
3562 | /* | ||
3563 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3418 | if (land != null) | 3564 | if (land != null) |
3419 | { | 3565 | { |
3420 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3566 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3422,26 +3568,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3422 | agent.startpos = land.LandData.UserLocation; | 3568 | agent.startpos = land.LandData.UserLocation; |
3423 | } | 3569 | } |
3424 | } | 3570 | } |
3571 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3425 | } | 3572 | } |
3426 | 3573 | ||
3427 | return true; | 3574 | return true; |
3428 | } | 3575 | } |
3429 | 3576 | ||
3430 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3577 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3431 | { | 3578 | { |
3432 | 3579 | reason = String.Empty; | |
3433 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3580 | if (Permissions.IsGod(agentID)) |
3434 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3581 | return true; |
3582 | |||
3583 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3584 | if (land == null) | ||
3585 | return false; | ||
3586 | |||
3587 | bool banned = land.IsBannedFromLand(agentID); | ||
3588 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3435 | 3589 | ||
3436 | if (banned || restricted) | 3590 | if (banned || restricted) |
3437 | { | 3591 | { |
3438 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3592 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3439 | if (nearestParcel != null) | 3593 | if (nearestParcel != null) |
3440 | { | 3594 | { |
3441 | //Move agent to nearest allowed | 3595 | //Move agent to nearest allowed |
3442 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3596 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3443 | agent.startpos.X = newPosition.X; | 3597 | posX = newPosition.X; |
3444 | agent.startpos.Y = newPosition.Y; | 3598 | posY = newPosition.Y; |
3445 | } | 3599 | } |
3446 | else | 3600 | else |
3447 | { | 3601 | { |
@@ -3503,7 +3657,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3503 | 3657 | ||
3504 | if (!m_strictAccessControl) return true; | 3658 | if (!m_strictAccessControl) return true; |
3505 | if (Permissions.IsGod(agent.AgentID)) return true; | 3659 | if (Permissions.IsGod(agent.AgentID)) return true; |
3506 | 3660 | ||
3507 | if (AuthorizationService != null) | 3661 | if (AuthorizationService != null) |
3508 | { | 3662 | { |
3509 | if (!AuthorizationService.IsAuthorizedForRegion( | 3663 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3511,14 +3665,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3511 | { | 3665 | { |
3512 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3666 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3513 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3667 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3514 | 3668 | ||
3515 | return false; | 3669 | return false; |
3516 | } | 3670 | } |
3517 | } | 3671 | } |
3518 | 3672 | ||
3519 | if (m_regInfo.EstateSettings != null) | 3673 | if (m_regInfo.EstateSettings != null) |
3520 | { | 3674 | { |
3521 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3675 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3522 | { | 3676 | { |
3523 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3677 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3524 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3678 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3708,6 +3862,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3708 | 3862 | ||
3709 | // We have to wait until the viewer contacts this region after receiving EAC. | 3863 | // We have to wait until the viewer contacts this region after receiving EAC. |
3710 | // That calls AddNewClient, which finally creates the ScenePresence | 3864 | // That calls AddNewClient, which finally creates the ScenePresence |
3865 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3866 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3867 | { | ||
3868 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3869 | return false; | ||
3870 | } | ||
3871 | |||
3711 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3872 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3712 | if (nearestParcel == null) | 3873 | if (nearestParcel == null) |
3713 | { | 3874 | { |
@@ -3723,7 +3884,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3723 | return false; | 3884 | return false; |
3724 | } | 3885 | } |
3725 | 3886 | ||
3726 | |||
3727 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3887 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3728 | 3888 | ||
3729 | if (childAgentUpdate != null) | 3889 | if (childAgentUpdate != null) |
@@ -3790,12 +3950,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3790 | return false; | 3950 | return false; |
3791 | } | 3951 | } |
3792 | 3952 | ||
3953 | public bool IncomingCloseAgent(UUID agentID) | ||
3954 | { | ||
3955 | return IncomingCloseAgent(agentID, false); | ||
3956 | } | ||
3957 | |||
3958 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3959 | { | ||
3960 | return IncomingCloseAgent(agentID, true); | ||
3961 | } | ||
3962 | |||
3793 | /// <summary> | 3963 | /// <summary> |
3794 | /// Tell a single agent to disconnect from the region. | 3964 | /// Tell a single agent to disconnect from the region. |
3795 | /// </summary> | 3965 | /// </summary> |
3796 | /// <param name="regionHandle"></param> | ||
3797 | /// <param name="agentID"></param> | 3966 | /// <param name="agentID"></param> |
3798 | public bool IncomingCloseAgent(UUID agentID) | 3967 | /// <param name="childOnly"></param> |
3968 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3799 | { | 3969 | { |
3800 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3970 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3801 | 3971 | ||
@@ -3807,7 +3977,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3807 | { | 3977 | { |
3808 | m_sceneGraph.removeUserCount(false); | 3978 | m_sceneGraph.removeUserCount(false); |
3809 | } | 3979 | } |
3810 | else | 3980 | else if (!childOnly) |
3811 | { | 3981 | { |
3812 | m_sceneGraph.removeUserCount(true); | 3982 | m_sceneGraph.removeUserCount(true); |
3813 | } | 3983 | } |
@@ -3823,9 +3993,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3823 | } | 3993 | } |
3824 | else | 3994 | else |
3825 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3995 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3996 | presence.ControllingClient.Close(false); | ||
3997 | } | ||
3998 | else if (!childOnly) | ||
3999 | { | ||
4000 | presence.ControllingClient.Close(true); | ||
3826 | } | 4001 | } |
3827 | |||
3828 | presence.ControllingClient.Close(); | ||
3829 | return true; | 4002 | return true; |
3830 | } | 4003 | } |
3831 | 4004 | ||
@@ -4420,34 +4593,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4420 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4593 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4421 | } | 4594 | } |
4422 | 4595 | ||
4423 | public int GetHealth() | 4596 | public int GetHealth(out int flags, out string message) |
4424 | { | 4597 | { |
4425 | // Returns: | 4598 | // Returns: |
4426 | // 1 = sim is up and accepting http requests. The heartbeat has | 4599 | // 1 = sim is up and accepting http requests. The heartbeat has |
4427 | // stopped and the sim is probably locked up, but a remote | 4600 | // stopped and the sim is probably locked up, but a remote |
4428 | // admin restart may succeed | 4601 | // admin restart may succeed |
4429 | // | 4602 | // |
4430 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4603 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4431 | // usable for people within and logins _may_ work | 4604 | // usable for people within |
4432 | // | 4605 | // |
4433 | // 3 = We have seen a new user enter within the past 4 minutes | 4606 | // 3 = Sim is up and one packet thread is running. Sim is |
4607 | // unstable and will not accept new logins | ||
4608 | // | ||
4609 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4610 | // likely usable | ||
4611 | // | ||
4612 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4434 | // which can be seen as positive confirmation of sim health | 4613 | // which can be seen as positive confirmation of sim health |
4435 | // | 4614 | // |
4615 | |||
4616 | flags = 0; | ||
4617 | message = String.Empty; | ||
4618 | |||
4619 | CheckHeartbeat(); | ||
4620 | |||
4621 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4622 | { | ||
4623 | // We're still starting | ||
4624 | // 0 means "in startup", it can't happen another way, since | ||
4625 | // to get here, we must be able to accept http connections | ||
4626 | return 0; | ||
4627 | } | ||
4628 | |||
4436 | int health=1; // Start at 1, means we're up | 4629 | int health=1; // Start at 1, means we're up |
4437 | 4630 | ||
4438 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4631 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4632 | { | ||
4439 | health+=1; | 4633 | health+=1; |
4440 | else | 4634 | flags |= 1; |
4635 | } | ||
4636 | |||
4637 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4638 | { | ||
4639 | health+=1; | ||
4640 | flags |= 2; | ||
4641 | } | ||
4642 | |||
4643 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4644 | { | ||
4645 | health+=1; | ||
4646 | flags |= 4; | ||
4647 | } | ||
4648 | |||
4649 | if (flags != 7) | ||
4441 | return health; | 4650 | return health; |
4442 | 4651 | ||
4443 | // A login in the last 4 mins? We can't be doing too badly | 4652 | // A login in the last 4 mins? We can't be doing too badly |
4444 | // | 4653 | // |
4445 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4654 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4446 | health++; | 4655 | health++; |
4447 | else | ||
4448 | return health; | ||
4449 | |||
4450 | CheckHeartbeat(); | ||
4451 | 4656 | ||
4452 | return health; | 4657 | return health; |
4453 | } | 4658 | } |
@@ -4640,7 +4845,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4640 | if (m_firstHeartbeat) | 4845 | if (m_firstHeartbeat) |
4641 | return; | 4846 | return; |
4642 | 4847 | ||
4643 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4848 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4644 | StartTimer(); | 4849 | StartTimer(); |
4645 | } | 4850 | } |
4646 | 4851 | ||
@@ -5054,6 +5259,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
5054 | } | 5259 | } |
5055 | } | 5260 | } |
5056 | 5261 | ||
5262 | // public void CleanDroppedAttachments() | ||
5263 | // { | ||
5264 | // List<SceneObjectGroup> objectsToDelete = | ||
5265 | // new List<SceneObjectGroup>(); | ||
5266 | // | ||
5267 | // lock (m_cleaningAttachments) | ||
5268 | // { | ||
5269 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5270 | // { | ||
5271 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5272 | // { | ||
5273 | // UUID agentID = grp.OwnerID; | ||
5274 | // if (agentID == UUID.Zero) | ||
5275 | // { | ||
5276 | // objectsToDelete.Add(grp); | ||
5277 | // return; | ||
5278 | // } | ||
5279 | // | ||
5280 | // ScenePresence sp = GetScenePresence(agentID); | ||
5281 | // if (sp == null) | ||
5282 | // { | ||
5283 | // objectsToDelete.Add(grp); | ||
5284 | // return; | ||
5285 | // } | ||
5286 | // } | ||
5287 | // }); | ||
5288 | // } | ||
5289 | // | ||
5290 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5291 | // { | ||
5292 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5293 | // DeleteSceneObject(grp, true); | ||
5294 | // } | ||
5295 | // } | ||
5296 | |||
5297 | public void ThreadAlive(int threadCode) | ||
5298 | { | ||
5299 | switch(threadCode) | ||
5300 | { | ||
5301 | case 1: // Incoming | ||
5302 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5303 | break; | ||
5304 | case 2: // Incoming | ||
5305 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5306 | break; | ||
5307 | } | ||
5308 | } | ||
5309 | |||
5057 | // This method is called across the simulation connector to | 5310 | // This method is called across the simulation connector to |
5058 | // determine if a given agent is allowed in this region | 5311 | // determine if a given agent is allowed in this region |
5059 | // AS A ROOT AGENT. Returning false here will prevent them | 5312 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5062,6 +5315,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5062 | // child agent creation, thereby emulating the SL behavior. | 5315 | // child agent creation, thereby emulating the SL behavior. |
5063 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5316 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5064 | { | 5317 | { |
5318 | reason = "You are banned from the region"; | ||
5319 | |||
5320 | if (Permissions.IsGod(agentID)) | ||
5321 | { | ||
5322 | reason = String.Empty; | ||
5323 | return true; | ||
5324 | } | ||
5325 | |||
5065 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5326 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5066 | 5327 | ||
5067 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5328 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5073,11 +5334,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5073 | } | 5334 | } |
5074 | } | 5335 | } |
5075 | 5336 | ||
5337 | ScenePresence presence = GetScenePresence(agentID); | ||
5338 | IClientAPI client = null; | ||
5339 | AgentCircuitData aCircuit = null; | ||
5340 | |||
5341 | if (presence != null) | ||
5342 | { | ||
5343 | client = presence.ControllingClient; | ||
5344 | if (client != null) | ||
5345 | aCircuit = client.RequestClientInfo(); | ||
5346 | } | ||
5347 | |||
5348 | // We may be called before there is a presence or a client. | ||
5349 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5350 | if (client == null) | ||
5351 | { | ||
5352 | aCircuit = new AgentCircuitData(); | ||
5353 | aCircuit.AgentID = agentID; | ||
5354 | aCircuit.firstname = String.Empty; | ||
5355 | aCircuit.lastname = String.Empty; | ||
5356 | } | ||
5357 | |||
5358 | try | ||
5359 | { | ||
5360 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5361 | { | ||
5362 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5363 | return false; | ||
5364 | } | ||
5365 | } | ||
5366 | catch (Exception e) | ||
5367 | { | ||
5368 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5369 | return false; | ||
5370 | } | ||
5371 | |||
5372 | if (position == Vector3.Zero) // Teleport | ||
5373 | { | ||
5374 | float posX = 128.0f; | ||
5375 | float posY = 128.0f; | ||
5376 | |||
5377 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5378 | { | ||
5379 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5380 | return false; | ||
5381 | } | ||
5382 | } | ||
5383 | else // Walking | ||
5384 | { | ||
5385 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5386 | if (land == null) | ||
5387 | return false; | ||
5388 | |||
5389 | bool banned = land.IsBannedFromLand(agentID); | ||
5390 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5391 | |||
5392 | if (banned || restricted) | ||
5393 | return false; | ||
5394 | } | ||
5395 | |||
5076 | reason = String.Empty; | 5396 | reason = String.Empty; |
5077 | return true; | 5397 | return true; |
5078 | } | 5398 | } |
5079 | 5399 | ||
5080 | /// <summary> | 5400 | public void StartTimerWatchdog() |
5401 | { | ||
5402 | m_timerWatchdog.Interval = 1000; | ||
5403 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5404 | m_timerWatchdog.AutoReset = true; | ||
5405 | m_timerWatchdog.Start(); | ||
5406 | } | ||
5407 | |||
5408 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5409 | { | ||
5410 | CheckHeartbeat(); | ||
5411 | } | ||
5412 | |||
5081 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5413 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5082 | /// autopilot that moves an avatar to a sit target!. | 5414 | /// autopilot that moves an avatar to a sit target!. |
5083 | /// </summary> | 5415 | /// </summary> |