diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 570 |
1 files changed, 442 insertions, 128 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 54956ee..d293a8b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -227,8 +227,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
227 | // TODO: need to figure out how allow client agents but deny | 227 | // TODO: need to figure out how allow client agents but deny |
228 | // root agents when ACL denies access to root agent | 228 | // root agents when ACL denies access to root agent |
229 | public bool m_strictAccessControl = true; | 229 | public bool m_strictAccessControl = true; |
230 | 230 | public bool m_seeIntoBannedRegion = false; | |
231 | public int MaxUndoCount { get; set; } | 231 | public int MaxUndoCount = 5; |
232 | 232 | ||
233 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 233 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
234 | public bool LoginLock = false; | 234 | public bool LoginLock = false; |
@@ -244,11 +244,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
244 | 244 | ||
245 | protected int m_splitRegionID; | 245 | protected int m_splitRegionID; |
246 | protected Timer m_restartWaitTimer = new Timer(); | 246 | protected Timer m_restartWaitTimer = new Timer(); |
247 | protected Timer m_timerWatchdog = new Timer(); | ||
247 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 248 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
248 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 249 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
249 | protected string m_simulatorVersion = "OpenSimulator Server"; | 250 | protected string m_simulatorVersion = "OpenSimulator Server"; |
250 | protected AgentCircuitManager m_authenticateHandler; | 251 | protected AgentCircuitManager m_authenticateHandler; |
251 | protected SceneCommunicationService m_sceneGridService; | 252 | protected SceneCommunicationService m_sceneGridService; |
253 | protected ISnmpModule m_snmpService = null; | ||
252 | 254 | ||
253 | protected ISimulationDataService m_SimulationDataService; | 255 | protected ISimulationDataService m_SimulationDataService; |
254 | protected IEstateDataService m_EstateDataService; | 256 | protected IEstateDataService m_EstateDataService; |
@@ -311,8 +313,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
311 | private int m_update_presences = 1; // Update scene presence movements | 313 | private int m_update_presences = 1; // Update scene presence movements |
312 | private int m_update_events = 1; | 314 | private int m_update_events = 1; |
313 | private int m_update_backup = 200; | 315 | private int m_update_backup = 200; |
314 | private int m_update_terrain = 50; | 316 | private int m_update_terrain = 1000; |
315 | // private int m_update_land = 1; | 317 | private int m_update_land = 10; |
316 | private int m_update_coarse_locations = 50; | 318 | private int m_update_coarse_locations = 50; |
317 | 319 | ||
318 | private int agentMS; | 320 | private int agentMS; |
@@ -325,13 +327,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
325 | private int backupMS; | 327 | private int backupMS; |
326 | private int terrainMS; | 328 | private int terrainMS; |
327 | private int landMS; | 329 | private int landMS; |
328 | private int spareMS; | ||
329 | 330 | ||
330 | /// <summary> | 331 | /// <summary> |
331 | /// Tick at which the last frame was processed. | 332 | /// Tick at which the last frame was processed. |
332 | /// </summary> | 333 | /// </summary> |
333 | private int m_lastFrameTick; | 334 | private int m_lastFrameTick; |
334 | 335 | ||
336 | public bool CombineRegions = false; | ||
335 | /// <summary> | 337 | /// <summary> |
336 | /// Tick at which the last maintenance run occurred. | 338 | /// Tick at which the last maintenance run occurred. |
337 | /// </summary> | 339 | /// </summary> |
@@ -351,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 353 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
352 | private volatile bool m_backingup; | 354 | private volatile bool m_backingup; |
353 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 355 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
354 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 356 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
355 | 357 | ||
356 | private string m_defaultScriptEngine; | 358 | private string m_defaultScriptEngine; |
357 | 359 | ||
@@ -360,6 +362,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
360 | /// </summary> | 362 | /// </summary> |
361 | private int m_LastLogin; | 363 | private int m_LastLogin; |
362 | 364 | ||
365 | private int m_lastIncoming; | ||
366 | private int m_lastOutgoing; | ||
367 | private int m_hbRestarts = 0; | ||
368 | |||
369 | |||
363 | /// <summary> | 370 | /// <summary> |
364 | /// Thread that runs the scene loop. | 371 | /// Thread that runs the scene loop. |
365 | /// </summary> | 372 | /// </summary> |
@@ -402,7 +409,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
402 | private volatile bool m_active; | 409 | private volatile bool m_active; |
403 | 410 | ||
404 | // private int m_lastUpdate; | 411 | // private int m_lastUpdate; |
405 | // private bool m_firstHeartbeat = true; | 412 | private bool m_firstHeartbeat = true; |
406 | 413 | ||
407 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 414 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
408 | private bool m_reprioritizationEnabled = true; | 415 | private bool m_reprioritizationEnabled = true; |
@@ -446,6 +453,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
446 | get { return m_sceneGridService; } | 453 | get { return m_sceneGridService; } |
447 | } | 454 | } |
448 | 455 | ||
456 | public ISnmpModule SnmpService | ||
457 | { | ||
458 | get | ||
459 | { | ||
460 | if (m_snmpService == null) | ||
461 | { | ||
462 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
463 | } | ||
464 | |||
465 | return m_snmpService; | ||
466 | } | ||
467 | } | ||
468 | |||
449 | public ISimulationDataService SimulationDataService | 469 | public ISimulationDataService SimulationDataService |
450 | { | 470 | { |
451 | get | 471 | get |
@@ -738,6 +758,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
738 | m_SimulationDataService = simDataService; | 758 | m_SimulationDataService = simDataService; |
739 | m_EstateDataService = estateDataService; | 759 | m_EstateDataService = estateDataService; |
740 | m_regionHandle = RegionInfo.RegionHandle; | 760 | m_regionHandle = RegionInfo.RegionHandle; |
761 | m_lastIncoming = 0; | ||
762 | m_lastOutgoing = 0; | ||
741 | 763 | ||
742 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 764 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
743 | m_asyncSceneObjectDeleter.Enabled = true; | 765 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -831,7 +853,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
831 | 853 | ||
832 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 854 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
833 | 855 | ||
834 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 856 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
835 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 857 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
836 | if (!UseBackup) | 858 | if (!UseBackup) |
837 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 859 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -839,10 +861,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | //Animation states | 861 | //Animation states |
840 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 862 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
841 | 863 | ||
842 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 864 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
843 | 865 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | |
844 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
845 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
846 | 866 | ||
847 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 867 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
848 | if (RegionInfo.NonphysPrimMin > 0) | 868 | if (RegionInfo.NonphysPrimMin > 0) |
@@ -863,11 +883,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
863 | } | 883 | } |
864 | 884 | ||
865 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 885 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
886 | |||
866 | if (RegionInfo.PhysPrimMax > 0) | 887 | if (RegionInfo.PhysPrimMax > 0) |
867 | { | 888 | { |
868 | m_maxPhys = RegionInfo.PhysPrimMax; | 889 | m_maxPhys = RegionInfo.PhysPrimMax; |
869 | } | 890 | } |
870 | 891 | ||
892 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
893 | if (RegionInfo.LinksetCapacity > 0) | ||
894 | { | ||
895 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
896 | } | ||
897 | |||
898 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
899 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
900 | |||
871 | // Here, if clamping is requested in either global or | 901 | // Here, if clamping is requested in either global or |
872 | // local config, it will be used | 902 | // local config, it will be used |
873 | // | 903 | // |
@@ -877,13 +907,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
877 | m_clampPrimSize = true; | 907 | m_clampPrimSize = true; |
878 | } | 908 | } |
879 | 909 | ||
880 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 910 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
881 | if (RegionInfo.LinksetCapacity > 0) | ||
882 | { | ||
883 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
884 | } | ||
885 | |||
886 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
887 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 911 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
888 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 912 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
889 | m_dontPersistBefore = | 913 | m_dontPersistBefore = |
@@ -894,11 +918,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
894 | m_persistAfter *= 10000000; | 918 | m_persistAfter *= 10000000; |
895 | 919 | ||
896 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 920 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
897 | 921 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
898 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
899 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
900 | 922 | ||
901 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 923 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
924 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
925 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
902 | 926 | ||
903 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; | 927 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; |
904 | 928 | ||
@@ -943,7 +967,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
943 | 967 | ||
944 | if (grant.Length > 0) | 968 | if (grant.Length > 0) |
945 | { | 969 | { |
946 | foreach (string viewer in grant.Split('|')) | 970 | foreach (string viewer in grant.Split(',')) |
947 | { | 971 | { |
948 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 972 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
949 | } | 973 | } |
@@ -955,7 +979,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
955 | 979 | ||
956 | if (grant.Length > 0) | 980 | if (grant.Length > 0) |
957 | { | 981 | { |
958 | foreach (string viewer in grant.Split('|')) | 982 | foreach (string viewer in grant.Split(',')) |
959 | { | 983 | { |
960 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 984 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
961 | } | 985 | } |
@@ -1015,6 +1039,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1015 | StatsReporter = new SimStatsReporter(this); | 1039 | StatsReporter = new SimStatsReporter(this); |
1016 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1040 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1017 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1041 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1042 | |||
1043 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1018 | } | 1044 | } |
1019 | 1045 | ||
1020 | public Scene(RegionInfo regInfo) : base(regInfo) | 1046 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1310,8 +1336,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1310 | // Stop all client threads. | 1336 | // Stop all client threads. |
1311 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1337 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1312 | 1338 | ||
1313 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1339 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1314 | EventManager.TriggerSceneShuttingDown(this); | 1340 | EventManager.TriggerSceneShuttingDown(this); |
1341 | |||
1342 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1343 | |||
1315 | Backup(false); | 1344 | Backup(false); |
1316 | m_sceneGraph.Close(); | 1345 | m_sceneGraph.Close(); |
1317 | 1346 | ||
@@ -1325,6 +1354,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1325 | // attempt to reference a null or disposed physics scene. | 1354 | // attempt to reference a null or disposed physics scene. |
1326 | if (PhysicsScene != null) | 1355 | if (PhysicsScene != null) |
1327 | { | 1356 | { |
1357 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1328 | PhysicsScene phys = PhysicsScene; | 1358 | PhysicsScene phys = PhysicsScene; |
1329 | // remove the physics engine from both Scene and SceneGraph | 1359 | // remove the physics engine from both Scene and SceneGraph |
1330 | PhysicsScene = null; | 1360 | PhysicsScene = null; |
@@ -1355,11 +1385,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1355 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1385 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1356 | if (m_heartbeatThread != null) | 1386 | if (m_heartbeatThread != null) |
1357 | { | 1387 | { |
1388 | m_hbRestarts++; | ||
1389 | if(m_hbRestarts > 10) | ||
1390 | Environment.Exit(1); | ||
1391 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1392 | |||
1393 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1394 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1395 | //proc.EnableRaisingEvents=false; | ||
1396 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1397 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1398 | //proc.Start(); | ||
1399 | //proc.WaitForExit(); | ||
1400 | //Thread.Sleep(1000); | ||
1401 | //Environment.Exit(1); | ||
1358 | m_heartbeatThread.Abort(); | 1402 | m_heartbeatThread.Abort(); |
1403 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1359 | m_heartbeatThread = null; | 1404 | m_heartbeatThread = null; |
1360 | } | 1405 | } |
1361 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1406 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1362 | 1407 | ||
1408 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1409 | |||
1410 | |||
1363 | m_heartbeatThread | 1411 | m_heartbeatThread |
1364 | = Watchdog.StartThread( | 1412 | = Watchdog.StartThread( |
1365 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1413 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1504,16 +1552,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1504 | endFrame = Frame + frames; | 1552 | endFrame = Frame + frames; |
1505 | 1553 | ||
1506 | float physicsFPS = 0f; | 1554 | float physicsFPS = 0f; |
1507 | int previousFrameTick, tmpMS; | 1555 | int tmpMS; |
1508 | int maintc = Util.EnvironmentTickCount(); | 1556 | int previousFrameTick; |
1557 | int maintc; | ||
1558 | int sleepMS; | ||
1559 | int framestart; | ||
1509 | 1560 | ||
1510 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1561 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1511 | { | 1562 | { |
1563 | framestart = Util.EnvironmentTickCount(); | ||
1512 | ++Frame; | 1564 | ++Frame; |
1513 | 1565 | ||
1514 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1566 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1515 | 1567 | ||
1516 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1568 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1517 | 1569 | ||
1518 | try | 1570 | try |
1519 | { | 1571 | { |
@@ -1567,6 +1619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1567 | m_sceneGraph.UpdatePresences(); | 1619 | m_sceneGraph.UpdatePresences(); |
1568 | 1620 | ||
1569 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1621 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1622 | |||
1570 | 1623 | ||
1571 | // Delete temp-on-rez stuff | 1624 | // Delete temp-on-rez stuff |
1572 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1625 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1648,34 +1701,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1648 | 1701 | ||
1649 | Watchdog.UpdateThread(); | 1702 | Watchdog.UpdateThread(); |
1650 | 1703 | ||
1704 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1705 | |||
1706 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1707 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1708 | StatsReporter.AddFPS(1); | ||
1709 | |||
1710 | StatsReporter.addAgentMS(agentMS); | ||
1711 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1712 | StatsReporter.addOtherMS(otherMS); | ||
1713 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1714 | |||
1651 | previousFrameTick = m_lastFrameTick; | 1715 | previousFrameTick = m_lastFrameTick; |
1652 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1716 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1653 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1717 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1654 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1718 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1655 | 1719 | ||
1720 | m_firstHeartbeat = false; | ||
1721 | |||
1722 | sleepMS = Util.EnvironmentTickCount(); | ||
1723 | |||
1656 | if (tmpMS > 0) | 1724 | if (tmpMS > 0) |
1657 | { | ||
1658 | Thread.Sleep(tmpMS); | 1725 | Thread.Sleep(tmpMS); |
1659 | spareMS += tmpMS; | ||
1660 | } | ||
1661 | 1726 | ||
1662 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | 1727 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1663 | maintc = Util.EnvironmentTickCount(); | 1728 | frameMS = Util.EnvironmentTickCountSubtract(framestart); |
1664 | 1729 | StatsReporter.addSleepMS(sleepMS); | |
1665 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1730 | StatsReporter.addFrameMS(frameMS); |
1666 | 1731 | ||
1667 | // if (Frame%m_update_avatars == 0) | 1732 | // if (Frame%m_update_avatars == 0) |
1668 | // UpdateInWorldTime(); | 1733 | // UpdateInWorldTime(); |
1669 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1670 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1671 | StatsReporter.AddFPS(1); | ||
1672 | 1734 | ||
1673 | StatsReporter.addFrameMS(frameMS); | ||
1674 | StatsReporter.addAgentMS(agentMS); | ||
1675 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1676 | StatsReporter.addOtherMS(otherMS); | ||
1677 | StatsReporter.AddSpareMS(spareMS); | ||
1678 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1679 | 1735 | ||
1680 | // Optionally warn if a frame takes double the amount of time that it should. | 1736 | // Optionally warn if a frame takes double the amount of time that it should. |
1681 | if (DebugUpdates | 1737 | if (DebugUpdates |
@@ -1692,7 +1748,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1692 | public void AddGroupTarget(SceneObjectGroup grp) | 1748 | public void AddGroupTarget(SceneObjectGroup grp) |
1693 | { | 1749 | { |
1694 | lock (m_groupsWithTargets) | 1750 | lock (m_groupsWithTargets) |
1695 | m_groupsWithTargets[grp.UUID] = grp; | 1751 | m_groupsWithTargets[grp.UUID] = 0; |
1696 | } | 1752 | } |
1697 | 1753 | ||
1698 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1754 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1703,18 +1759,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1703 | 1759 | ||
1704 | private void CheckAtTargets() | 1760 | private void CheckAtTargets() |
1705 | { | 1761 | { |
1706 | List<SceneObjectGroup> objs = null; | 1762 | List<UUID> objs = null; |
1707 | 1763 | ||
1708 | lock (m_groupsWithTargets) | 1764 | lock (m_groupsWithTargets) |
1709 | { | 1765 | { |
1710 | if (m_groupsWithTargets.Count != 0) | 1766 | if (m_groupsWithTargets.Count != 0) |
1711 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1767 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1712 | } | 1768 | } |
1713 | 1769 | ||
1714 | if (objs != null) | 1770 | if (objs != null) |
1715 | { | 1771 | { |
1716 | foreach (SceneObjectGroup entry in objs) | 1772 | foreach (UUID entry in objs) |
1717 | entry.checkAtTargets(); | 1773 | { |
1774 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1775 | if (grp == null) | ||
1776 | m_groupsWithTargets.Remove(entry); | ||
1777 | else | ||
1778 | grp.checkAtTargets(); | ||
1779 | } | ||
1718 | } | 1780 | } |
1719 | } | 1781 | } |
1720 | 1782 | ||
@@ -1793,7 +1855,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1793 | msg.fromAgentName = "Server"; | 1855 | msg.fromAgentName = "Server"; |
1794 | msg.dialog = (byte)19; // Object msg | 1856 | msg.dialog = (byte)19; // Object msg |
1795 | msg.fromGroup = false; | 1857 | msg.fromGroup = false; |
1796 | msg.offline = (byte)0; | 1858 | msg.offline = (byte)1; |
1797 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1859 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1798 | msg.Position = Vector3.Zero; | 1860 | msg.Position = Vector3.Zero; |
1799 | msg.RegionID = RegionInfo.RegionID.Guid; | 1861 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2022,7 +2084,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2022 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2084 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
2023 | } | 2085 | } |
2024 | 2086 | ||
2025 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2087 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
2026 | { | 2088 | { |
2027 | if (PhysicsScene == null) | 2089 | if (PhysicsScene == null) |
2028 | return null; | 2090 | return null; |
@@ -2044,14 +2106,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2044 | /// <returns></returns> | 2106 | /// <returns></returns> |
2045 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2107 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2046 | { | 2108 | { |
2109 | |||
2110 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2111 | Vector3 wpos = Vector3.Zero; | ||
2112 | // Check for water surface intersection from above | ||
2113 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2114 | { | ||
2115 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2116 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2117 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2118 | wpos.Z = wheight; | ||
2119 | } | ||
2120 | |||
2047 | Vector3 pos = Vector3.Zero; | 2121 | Vector3 pos = Vector3.Zero; |
2048 | if (RayEndIsIntersection == (byte)1) | 2122 | if (RayEndIsIntersection == (byte)1) |
2049 | { | 2123 | { |
2050 | pos = RayEnd; | 2124 | pos = RayEnd; |
2051 | return pos; | ||
2052 | } | 2125 | } |
2053 | 2126 | else if (RayTargetID != UUID.Zero) | |
2054 | if (RayTargetID != UUID.Zero) | ||
2055 | { | 2127 | { |
2056 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2128 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2057 | 2129 | ||
@@ -2073,7 +2145,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2073 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2145 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2074 | 2146 | ||
2075 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2147 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2076 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2148 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2077 | float ScaleOffset = 0.5f; | 2149 | float ScaleOffset = 0.5f; |
2078 | 2150 | ||
2079 | // If we hit something | 2151 | // If we hit something |
@@ -2096,13 +2168,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2096 | //pos.Z -= 0.25F; | 2168 | //pos.Z -= 0.25F; |
2097 | 2169 | ||
2098 | } | 2170 | } |
2099 | |||
2100 | return pos; | ||
2101 | } | 2171 | } |
2102 | else | 2172 | else |
2103 | { | 2173 | { |
2104 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2174 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2105 | |||
2106 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2175 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2107 | 2176 | ||
2108 | // Un-comment the following line to print the raytrace results to the console. | 2177 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2111,13 +2180,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2111 | if (ei.HitTF) | 2180 | if (ei.HitTF) |
2112 | { | 2181 | { |
2113 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2182 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2114 | } else | 2183 | } |
2184 | else | ||
2115 | { | 2185 | { |
2116 | // fall back to our stupid functionality | 2186 | // fall back to our stupid functionality |
2117 | pos = RayEnd; | 2187 | pos = RayEnd; |
2118 | } | 2188 | } |
2119 | |||
2120 | return pos; | ||
2121 | } | 2189 | } |
2122 | } | 2190 | } |
2123 | else | 2191 | else |
@@ -2128,8 +2196,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2128 | //increase height so its above the ground. | 2196 | //increase height so its above the ground. |
2129 | //should be getting the normal of the ground at the rez point and using that? | 2197 | //should be getting the normal of the ground at the rez point and using that? |
2130 | pos.Z += scale.Z / 2f; | 2198 | pos.Z += scale.Z / 2f; |
2131 | return pos; | 2199 | // return pos; |
2132 | } | 2200 | } |
2201 | |||
2202 | // check against posible water intercept | ||
2203 | if (wpos.Z > pos.Z) pos = wpos; | ||
2204 | return pos; | ||
2133 | } | 2205 | } |
2134 | 2206 | ||
2135 | 2207 | ||
@@ -2220,12 +2292,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2220 | { | 2292 | { |
2221 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2293 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2222 | { | 2294 | { |
2295 | sceneObject.IsDeleted = false; | ||
2223 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2296 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2224 | return true; | 2297 | return true; |
2225 | } | 2298 | } |
2226 | 2299 | ||
2227 | return false; | 2300 | return false; |
2228 | |||
2229 | } | 2301 | } |
2230 | 2302 | ||
2231 | /// <summary> | 2303 | /// <summary> |
@@ -2317,6 +2389,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2317 | /// </summary> | 2389 | /// </summary> |
2318 | public void DeleteAllSceneObjects() | 2390 | public void DeleteAllSceneObjects() |
2319 | { | 2391 | { |
2392 | DeleteAllSceneObjects(false); | ||
2393 | } | ||
2394 | |||
2395 | /// <summary> | ||
2396 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2397 | /// </summary> | ||
2398 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2399 | { | ||
2400 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2320 | lock (Entities) | 2401 | lock (Entities) |
2321 | { | 2402 | { |
2322 | EntityBase[] entities = Entities.GetEntities(); | 2403 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2325,11 +2406,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2325 | if (e is SceneObjectGroup) | 2406 | if (e is SceneObjectGroup) |
2326 | { | 2407 | { |
2327 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2408 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2328 | if (!sog.IsAttachment) | 2409 | if (sog != null && !sog.IsAttachment) |
2329 | DeleteSceneObject((SceneObjectGroup)e, false); | 2410 | { |
2411 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2412 | { | ||
2413 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2414 | } | ||
2415 | else | ||
2416 | { | ||
2417 | toReturn.Add((SceneObjectGroup)e); | ||
2418 | } | ||
2419 | } | ||
2330 | } | 2420 | } |
2331 | } | 2421 | } |
2332 | } | 2422 | } |
2423 | if (toReturn.Count > 0) | ||
2424 | { | ||
2425 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2426 | } | ||
2333 | } | 2427 | } |
2334 | 2428 | ||
2335 | /// <summary> | 2429 | /// <summary> |
@@ -2360,6 +2454,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2360 | else | 2454 | else |
2361 | group.StopScriptInstances(); | 2455 | group.StopScriptInstances(); |
2362 | 2456 | ||
2457 | List<UUID> avatars = group.GetSittingAvatars(); | ||
2458 | foreach (UUID av in avatars) | ||
2459 | { | ||
2460 | ScenePresence p = GetScenePresence(av); | ||
2461 | if (p != null) | ||
2462 | p.StandUp(); | ||
2463 | } | ||
2464 | |||
2363 | SceneObjectPart[] partList = group.Parts; | 2465 | SceneObjectPart[] partList = group.Parts; |
2364 | 2466 | ||
2365 | foreach (SceneObjectPart part in partList) | 2467 | foreach (SceneObjectPart part in partList) |
@@ -2387,6 +2489,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2387 | } | 2489 | } |
2388 | 2490 | ||
2389 | group.DeleteGroupFromScene(silent); | 2491 | group.DeleteGroupFromScene(silent); |
2492 | if (!silent) | ||
2493 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2390 | 2494 | ||
2391 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2495 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2392 | } | 2496 | } |
@@ -2676,7 +2780,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2676 | // If the user is banned, we won't let any of their objects | 2780 | // If the user is banned, we won't let any of their objects |
2677 | // enter. Period. | 2781 | // enter. Period. |
2678 | // | 2782 | // |
2679 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2783 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2680 | { | 2784 | { |
2681 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2785 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2682 | return false; | 2786 | return false; |
@@ -2731,6 +2835,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2731 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2835 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2732 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2836 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2733 | { | 2837 | { |
2838 | if (sceneObject.OwnerID == UUID.Zero) | ||
2839 | { | ||
2840 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2841 | return false; | ||
2842 | } | ||
2843 | |||
2844 | // If the user is banned, we won't let any of their objects | ||
2845 | // enter. Period. | ||
2846 | // | ||
2847 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2848 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2849 | { | ||
2850 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2851 | |||
2852 | return false; | ||
2853 | } | ||
2854 | |||
2734 | // Force allocation of new LocalId | 2855 | // Force allocation of new LocalId |
2735 | // | 2856 | // |
2736 | SceneObjectPart[] parts = sceneObject.Parts; | 2857 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2767,16 +2888,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2767 | // information that this is due to a teleport/border cross rather than an ordinary attachment. | 2888 | // information that this is due to a teleport/border cross rather than an ordinary attachment. |
2768 | // We currently do this in Scene.MakeRootAgent() instead. | 2889 | // We currently do this in Scene.MakeRootAgent() instead. |
2769 | if (AttachmentsModule != null) | 2890 | if (AttachmentsModule != null) |
2770 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); | 2891 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); |
2771 | } | 2892 | } |
2772 | else | 2893 | else |
2773 | { | 2894 | { |
2895 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2774 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2896 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2775 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2897 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2776 | } | 2898 | } |
2899 | if (sceneObject.OwnerID == UUID.Zero) | ||
2900 | { | ||
2901 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2902 | return false; | ||
2903 | } | ||
2777 | } | 2904 | } |
2778 | else | 2905 | else |
2779 | { | 2906 | { |
2907 | if (sceneObject.OwnerID == UUID.Zero) | ||
2908 | { | ||
2909 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2910 | return false; | ||
2911 | } | ||
2780 | AddRestoredSceneObject(sceneObject, true, false); | 2912 | AddRestoredSceneObject(sceneObject, true, false); |
2781 | } | 2913 | } |
2782 | 2914 | ||
@@ -2793,6 +2925,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2793 | return 2; // StateSource.PrimCrossing | 2925 | return 2; // StateSource.PrimCrossing |
2794 | } | 2926 | } |
2795 | 2927 | ||
2928 | public int GetUserFlags(UUID user) | ||
2929 | { | ||
2930 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2931 | /* | ||
2932 | ScenePresence sp; | ||
2933 | if (TryGetScenePresence(user, out sp)) | ||
2934 | { | ||
2935 | return sp.UserFlags; | ||
2936 | } | ||
2937 | else | ||
2938 | { | ||
2939 | */ | ||
2940 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2941 | if (uac == null) | ||
2942 | return 0; | ||
2943 | return uac.UserFlags; | ||
2944 | //} | ||
2945 | } | ||
2796 | #endregion | 2946 | #endregion |
2797 | 2947 | ||
2798 | #region Add/Remove Avatar Methods | 2948 | #region Add/Remove Avatar Methods |
@@ -2825,7 +2975,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2825 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2975 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2826 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2976 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2827 | 2977 | ||
2828 | // CheckHeartbeat(); | 2978 | CheckHeartbeat(); |
2829 | 2979 | ||
2830 | sp = GetScenePresence(client.AgentId); | 2980 | sp = GetScenePresence(client.AgentId); |
2831 | 2981 | ||
@@ -2843,6 +2993,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2843 | SubscribeToClientEvents(client); | 2993 | SubscribeToClientEvents(client); |
2844 | 2994 | ||
2845 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | 2995 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
2996 | InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
2997 | if (cof == null) | ||
2998 | sp.COF = UUID.Zero; | ||
2999 | else | ||
3000 | sp.COF = cof.ID; | ||
3001 | |||
3002 | m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); | ||
2846 | m_eventManager.TriggerOnNewPresence(sp); | 3003 | m_eventManager.TriggerOnNewPresence(sp); |
2847 | 3004 | ||
2848 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | 3005 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; |
@@ -2957,19 +3114,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2957 | // and the scene presence and the client, if they exist | 3114 | // and the scene presence and the client, if they exist |
2958 | try | 3115 | try |
2959 | { | 3116 | { |
2960 | // We need to wait for the client to make UDP contact first. | 3117 | ScenePresence sp = GetScenePresence(agentID); |
2961 | // It's the UDP contact that creates the scene presence | 3118 | |
2962 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2963 | if (sp != null) | 3119 | if (sp != null) |
2964 | { | 3120 | { |
2965 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3121 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2966 | |||
2967 | sp.ControllingClient.Close(); | 3122 | sp.ControllingClient.Close(); |
2968 | } | 3123 | } |
2969 | else | 3124 | |
2970 | { | ||
2971 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2972 | } | ||
2973 | // BANG! SLASH! | 3125 | // BANG! SLASH! |
2974 | m_authenticateHandler.RemoveCircuit(agentID); | 3126 | m_authenticateHandler.RemoveCircuit(agentID); |
2975 | 3127 | ||
@@ -3014,6 +3166,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3014 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3166 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
3015 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3167 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
3016 | 3168 | ||
3169 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3170 | |||
3017 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3171 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3018 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3172 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3019 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3173 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3070,6 +3224,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3070 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3224 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3071 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3225 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3072 | client.OnCopyInventoryItem += CopyInventoryItem; | 3226 | client.OnCopyInventoryItem += CopyInventoryItem; |
3227 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3073 | client.OnMoveInventoryItem += MoveInventoryItem; | 3228 | client.OnMoveInventoryItem += MoveInventoryItem; |
3074 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3229 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3075 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3230 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3139,6 +3294,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3139 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3294 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3140 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3295 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3141 | 3296 | ||
3297 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3298 | |||
3142 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3299 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3143 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3300 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3144 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3301 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3444,7 +3601,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3444 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 3601 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3445 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 3602 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3446 | if (closeChildAgents && CapsModule != null) | 3603 | if (closeChildAgents && CapsModule != null) |
3447 | CapsModule.RemoveCaps(agentID); | 3604 | CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); |
3448 | 3605 | ||
3449 | if (closeChildAgents && !isChildAgent) | 3606 | if (closeChildAgents && !isChildAgent) |
3450 | { | 3607 | { |
@@ -3477,6 +3634,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3477 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3634 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3478 | if (AgentTransactionsModule != null) | 3635 | if (AgentTransactionsModule != null) |
3479 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3636 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3637 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3480 | } | 3638 | } |
3481 | catch (Exception e) | 3639 | catch (Exception e) |
3482 | { | 3640 | { |
@@ -3670,15 +3828,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3670 | agent.firstname, agent.lastname, agent.Viewer); | 3828 | agent.firstname, agent.lastname, agent.Viewer); |
3671 | reason = "Access denied, your viewer is banned by the region owner"; | 3829 | reason = "Access denied, your viewer is banned by the region owner"; |
3672 | return false; | 3830 | return false; |
3673 | } | 3831 | } |
3674 | 3832 | ||
3675 | ILandObject land; | 3833 | ScenePresence sp = GetScenePresence(agent.AgentID); |
3676 | 3834 | ||
3677 | lock (agent) | 3835 | // If we have noo presence here or if that presence is a zombie root |
3836 | // presence that will be kicled, we need a new CAPS object. | ||
3837 | if (sp == null || (sp != null && !sp.IsChildAgent)) | ||
3678 | { | 3838 | { |
3679 | ScenePresence sp = GetScenePresence(agent.AgentID); | 3839 | if (CapsModule != null) |
3680 | 3840 | { | |
3681 | if (sp != null && !sp.IsChildAgent) | 3841 | lock (agent) |
3842 | { | ||
3843 | CapsModule.SetAgentCapsSeeds(agent); | ||
3844 | CapsModule.CreateCaps(agent.AgentID, agent.circuitcode); | ||
3845 | } | ||
3846 | } | ||
3847 | } | ||
3848 | |||
3849 | if (sp != null) | ||
3850 | { | ||
3851 | if (!sp.IsChildAgent) | ||
3682 | { | 3852 | { |
3683 | // We have a zombie from a crashed session. | 3853 | // We have a zombie from a crashed session. |
3684 | // Or the same user is trying to be root twice here, won't work. | 3854 | // Or the same user is trying to be root twice here, won't work. |
@@ -3686,31 +3856,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
3686 | m_log.WarnFormat( | 3856 | m_log.WarnFormat( |
3687 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | 3857 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", |
3688 | sp.Name, sp.UUID, RegionInfo.RegionName); | 3858 | sp.Name, sp.UUID, RegionInfo.RegionName); |
3859 | |||
3689 | 3860 | ||
3690 | if (sp.ControllingClient != null) | 3861 | if (sp.ControllingClient != null) |
3691 | sp.ControllingClient.Close(true); | 3862 | sp.ControllingClient.Close(true, true); |
3692 | 3863 | ||
3693 | sp = null; | 3864 | sp = null; |
3694 | } | 3865 | } |
3866 | } | ||
3695 | 3867 | ||
3868 | lock (agent) | ||
3869 | { | ||
3696 | // Optimistic: add or update the circuit data with the new agent circuit data and teleport flags. | 3870 | // Optimistic: add or update the circuit data with the new agent circuit data and teleport flags. |
3697 | // We need the circuit data here for some of the subsequent checks. (groups, for example) | 3871 | // We need the circuit data here for some of the subsequent checks. (groups, for example) |
3698 | // If the checks fail, we remove the circuit. | 3872 | // If the checks fail, we remove the circuit. |
3699 | agent.teleportFlags = teleportFlags; | 3873 | agent.teleportFlags = teleportFlags; |
3700 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3874 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3701 | 3875 | ||
3702 | land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3703 | |||
3704 | // On login test land permisions | 3876 | // On login test land permisions |
3705 | if (vialogin) | 3877 | if (vialogin) |
3706 | { | 3878 | { |
3707 | if (land != null && !TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | 3879 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3880 | if (cache != null) | ||
3881 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3882 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3708 | { | 3883 | { |
3884 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3709 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3885 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); |
3710 | return false; | 3886 | return false; |
3711 | } | 3887 | } |
3712 | } | 3888 | } |
3713 | 3889 | ||
3714 | if (sp == null) // We don't have an [child] agent here already | 3890 | if (sp == null) // We don't have an [child] agent here already |
3715 | { | 3891 | { |
3716 | if (requirePresenceLookup) | 3892 | if (requirePresenceLookup) |
@@ -3732,13 +3908,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3732 | return false; | 3908 | return false; |
3733 | } | 3909 | } |
3734 | } | 3910 | } |
3735 | 3911 | ||
3736 | try | 3912 | try |
3737 | { | 3913 | { |
3738 | if (!AuthorizeUser(agent, out reason)) | 3914 | // Always check estate if this is a login. Always |
3915 | // check if banned regions are to be blacked out. | ||
3916 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3739 | { | 3917 | { |
3740 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3918 | if (!AuthorizeUser(agent, out reason)) |
3741 | return false; | 3919 | { |
3920 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | ||
3921 | return false; | ||
3922 | } | ||
3742 | } | 3923 | } |
3743 | } | 3924 | } |
3744 | catch (Exception e) | 3925 | catch (Exception e) |
@@ -3749,32 +3930,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3749 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3930 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); |
3750 | return false; | 3931 | return false; |
3751 | } | 3932 | } |
3752 | 3933 | ||
3753 | m_log.InfoFormat( | 3934 | m_log.InfoFormat( |
3754 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 3935 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3755 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3936 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3756 | agent.AgentID, agent.circuitcode); | 3937 | agent.AgentID, agent.circuitcode); |
3757 | 3938 | ||
3758 | if (CapsModule != null) | ||
3759 | { | ||
3760 | CapsModule.SetAgentCapsSeeds(agent); | ||
3761 | CapsModule.CreateCaps(agent.AgentID); | ||
3762 | } | ||
3763 | } | 3939 | } |
3764 | else | 3940 | else |
3765 | { | 3941 | { |
3766 | // Let the SP know how we got here. This has a lot of interesting | 3942 | // Let the SP know how we got here. This has a lot of interesting |
3767 | // uses down the line. | 3943 | // uses down the line. |
3768 | sp.TeleportFlags = (TPFlags)teleportFlags; | 3944 | sp.TeleportFlags = (TPFlags)teleportFlags; |
3769 | 3945 | ||
3770 | if (sp.IsChildAgent) | 3946 | if (sp.IsChildAgent) |
3771 | { | 3947 | { |
3772 | m_log.DebugFormat( | 3948 | m_log.DebugFormat( |
3773 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3949 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
3774 | agent.AgentID, RegionInfo.RegionName); | 3950 | agent.AgentID, RegionInfo.RegionName); |
3775 | 3951 | ||
3776 | sp.AdjustKnownSeeds(); | 3952 | sp.AdjustKnownSeeds(); |
3777 | 3953 | ||
3778 | if (CapsModule != null) | 3954 | if (CapsModule != null) |
3779 | CapsModule.SetAgentCapsSeeds(agent); | 3955 | CapsModule.SetAgentCapsSeeds(agent); |
3780 | } | 3956 | } |
@@ -3786,6 +3962,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3786 | CacheUserName(null, agent); | 3962 | CacheUserName(null, agent); |
3787 | } | 3963 | } |
3788 | 3964 | ||
3965 | if (CapsModule != null) | ||
3966 | { | ||
3967 | CapsModule.ActivateCaps(agent.circuitcode); | ||
3968 | } | ||
3969 | |||
3789 | if (vialogin) | 3970 | if (vialogin) |
3790 | { | 3971 | { |
3791 | // CleanDroppedAttachments(); | 3972 | // CleanDroppedAttachments(); |
@@ -3877,6 +4058,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3877 | } | 4058 | } |
3878 | 4059 | ||
3879 | // Honor parcel landing type and position. | 4060 | // Honor parcel landing type and position. |
4061 | /* | ||
4062 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3880 | if (land != null) | 4063 | if (land != null) |
3881 | { | 4064 | { |
3882 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4065 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3884,6 +4067,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3884 | agent.startpos = land.LandData.UserLocation; | 4067 | agent.startpos = land.LandData.UserLocation; |
3885 | } | 4068 | } |
3886 | } | 4069 | } |
4070 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3887 | } | 4071 | } |
3888 | 4072 | ||
3889 | return true; | 4073 | return true; |
@@ -3981,7 +4165,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3981 | 4165 | ||
3982 | if (!m_strictAccessControl) return true; | 4166 | if (!m_strictAccessControl) return true; |
3983 | if (Permissions.IsGod(agent.AgentID)) return true; | 4167 | if (Permissions.IsGod(agent.AgentID)) return true; |
3984 | 4168 | ||
3985 | if (AuthorizationService != null) | 4169 | if (AuthorizationService != null) |
3986 | { | 4170 | { |
3987 | if (!AuthorizationService.IsAuthorizedForRegion( | 4171 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3996,7 +4180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3996 | 4180 | ||
3997 | if (RegionInfo.EstateSettings != null) | 4181 | if (RegionInfo.EstateSettings != null) |
3998 | { | 4182 | { |
3999 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4183 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
4000 | { | 4184 | { |
4001 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4185 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
4002 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4186 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4184,6 +4368,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4184 | m_log.DebugFormat( | 4368 | m_log.DebugFormat( |
4185 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4369 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4186 | 4370 | ||
4371 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4372 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4373 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4374 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4375 | { | ||
4376 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4377 | return false; | ||
4378 | } | ||
4379 | |||
4187 | // TODO: This check should probably be in QueryAccess(). | 4380 | // TODO: This check should probably be in QueryAccess(). |
4188 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4381 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4189 | if (nearestParcel == null) | 4382 | if (nearestParcel == null) |
@@ -4248,7 +4441,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4248 | /// <param name='agentID'></param> | 4441 | /// <param name='agentID'></param> |
4249 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4442 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4250 | { | 4443 | { |
4251 | int ntimes = 10; | 4444 | int ntimes = 30; |
4252 | ScenePresence sp = null; | 4445 | ScenePresence sp = null; |
4253 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4446 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4254 | Thread.Sleep(1000); | 4447 | Thread.Sleep(1000); |
@@ -4278,6 +4471,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4278 | return false; | 4471 | return false; |
4279 | } | 4472 | } |
4280 | 4473 | ||
4474 | public bool IncomingCloseAgent(UUID agentID) | ||
4475 | { | ||
4476 | return IncomingCloseAgent(agentID, false); | ||
4477 | } | ||
4478 | |||
4479 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4480 | { | ||
4481 | return IncomingCloseAgent(agentID, true); | ||
4482 | } | ||
4483 | |||
4281 | /// <summary> | 4484 | /// <summary> |
4282 | /// Tell a single agent to disconnect from the region. | 4485 | /// Tell a single agent to disconnect from the region. |
4283 | /// </summary> | 4486 | /// </summary> |
@@ -4293,7 +4496,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4293 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4496 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4294 | if (presence != null) | 4497 | if (presence != null) |
4295 | { | 4498 | { |
4296 | presence.ControllingClient.Close(force); | 4499 | presence.ControllingClient.Close(force, force); |
4297 | return true; | 4500 | return true; |
4298 | } | 4501 | } |
4299 | 4502 | ||
@@ -4911,7 +5114,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4911 | { | 5114 | { |
4912 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5115 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
4913 | { | 5116 | { |
4914 | if (grp.RootPart.Expires <= DateTime.Now) | 5117 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
4915 | DeleteSceneObject(grp, false); | 5118 | DeleteSceneObject(grp, false); |
4916 | } | 5119 | } |
4917 | } | 5120 | } |
@@ -4925,35 +5128,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4925 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5128 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4926 | } | 5129 | } |
4927 | 5130 | ||
4928 | public int GetHealth() | 5131 | public int GetHealth(out int flags, out string message) |
4929 | { | 5132 | { |
4930 | // Returns: | 5133 | // Returns: |
4931 | // 1 = sim is up and accepting http requests. The heartbeat has | 5134 | // 1 = sim is up and accepting http requests. The heartbeat has |
4932 | // stopped and the sim is probably locked up, but a remote | 5135 | // stopped and the sim is probably locked up, but a remote |
4933 | // admin restart may succeed | 5136 | // admin restart may succeed |
4934 | // | 5137 | // |
4935 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5138 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4936 | // usable for people within and logins _may_ work | 5139 | // usable for people within |
5140 | // | ||
5141 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5142 | // unstable and will not accept new logins | ||
4937 | // | 5143 | // |
4938 | // 3 = We have seen a new user enter within the past 4 minutes | 5144 | // 4 = Sim is up and both packet threads are running. Sim is |
5145 | // likely usable | ||
5146 | // | ||
5147 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4939 | // which can be seen as positive confirmation of sim health | 5148 | // which can be seen as positive confirmation of sim health |
4940 | // | 5149 | // |
5150 | |||
5151 | flags = 0; | ||
5152 | message = String.Empty; | ||
5153 | |||
5154 | CheckHeartbeat(); | ||
5155 | |||
5156 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5157 | { | ||
5158 | // We're still starting | ||
5159 | // 0 means "in startup", it can't happen another way, since | ||
5160 | // to get here, we must be able to accept http connections | ||
5161 | return 0; | ||
5162 | } | ||
5163 | |||
4941 | int health=1; // Start at 1, means we're up | 5164 | int health=1; // Start at 1, means we're up |
4942 | 5165 | ||
4943 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5166 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4944 | health += 1; | 5167 | { |
5168 | health+=1; | ||
5169 | flags |= 1; | ||
5170 | } | ||
5171 | |||
5172 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5173 | { | ||
5174 | health+=1; | ||
5175 | flags |= 2; | ||
5176 | } | ||
5177 | |||
5178 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5179 | { | ||
5180 | health+=1; | ||
5181 | flags |= 4; | ||
5182 | } | ||
4945 | else | 5183 | else |
5184 | { | ||
5185 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5186 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5187 | proc.EnableRaisingEvents=false; | ||
5188 | proc.StartInfo.FileName = "/bin/kill"; | ||
5189 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5190 | proc.Start(); | ||
5191 | proc.WaitForExit(); | ||
5192 | Thread.Sleep(1000); | ||
5193 | Environment.Exit(1); | ||
5194 | } | ||
5195 | |||
5196 | if (flags != 7) | ||
4946 | return health; | 5197 | return health; |
4947 | 5198 | ||
4948 | // A login in the last 4 mins? We can't be doing too badly | 5199 | // A login in the last 4 mins? We can't be doing too badly |
4949 | // | 5200 | // |
4950 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5201 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4951 | health++; | 5202 | health++; |
4952 | else | 5203 | else |
4953 | return health; | 5204 | return health; |
4954 | 5205 | ||
4955 | // CheckHeartbeat(); | ||
4956 | |||
4957 | return health; | 5206 | return health; |
4958 | } | 5207 | } |
4959 | 5208 | ||
@@ -5041,7 +5290,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5041 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5290 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5042 | if (wasUsingPhysics) | 5291 | if (wasUsingPhysics) |
5043 | { | 5292 | { |
5044 | jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock | 5293 | jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock |
5045 | } | 5294 | } |
5046 | } | 5295 | } |
5047 | 5296 | ||
@@ -5140,14 +5389,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5140 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5389 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5141 | } | 5390 | } |
5142 | 5391 | ||
5143 | // private void CheckHeartbeat() | 5392 | private void CheckHeartbeat() |
5144 | // { | 5393 | { |
5145 | // if (m_firstHeartbeat) | 5394 | if (m_firstHeartbeat) |
5146 | // return; | 5395 | return; |
5147 | // | 5396 | |
5148 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5397 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5149 | // StartTimer(); | 5398 | Start(); |
5150 | // } | 5399 | } |
5151 | 5400 | ||
5152 | public override ISceneObject DeserializeObject(string representation) | 5401 | public override ISceneObject DeserializeObject(string representation) |
5153 | { | 5402 | { |
@@ -5205,7 +5454,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5205 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | 5454 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); |
5206 | 5455 | ||
5207 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | 5456 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); |
5208 | 5457 | ||
5209 | return nearestRegionEdgePoint; | 5458 | return nearestRegionEdgePoint; |
5210 | } | 5459 | } |
5211 | 5460 | ||
@@ -5459,7 +5708,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5459 | mapModule.GenerateMaptile(); | 5708 | mapModule.GenerateMaptile(); |
5460 | } | 5709 | } |
5461 | 5710 | ||
5462 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5711 | // public void CleanDroppedAttachments() |
5712 | // { | ||
5713 | // List<SceneObjectGroup> objectsToDelete = | ||
5714 | // new List<SceneObjectGroup>(); | ||
5715 | // | ||
5716 | // lock (m_cleaningAttachments) | ||
5717 | // { | ||
5718 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5719 | // { | ||
5720 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5721 | // { | ||
5722 | // UUID agentID = grp.OwnerID; | ||
5723 | // if (agentID == UUID.Zero) | ||
5724 | // { | ||
5725 | // objectsToDelete.Add(grp); | ||
5726 | // return; | ||
5727 | // } | ||
5728 | // | ||
5729 | // ScenePresence sp = GetScenePresence(agentID); | ||
5730 | // if (sp == null) | ||
5731 | // { | ||
5732 | // objectsToDelete.Add(grp); | ||
5733 | // return; | ||
5734 | // } | ||
5735 | // } | ||
5736 | // }); | ||
5737 | // } | ||
5738 | // | ||
5739 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5740 | // { | ||
5741 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5742 | // DeleteSceneObject(grp, true); | ||
5743 | // } | ||
5744 | // } | ||
5745 | |||
5746 | public void ThreadAlive(int threadCode) | ||
5747 | { | ||
5748 | switch(threadCode) | ||
5749 | { | ||
5750 | case 1: // Incoming | ||
5751 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5752 | break; | ||
5753 | case 2: // Incoming | ||
5754 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5755 | break; | ||
5756 | } | ||
5757 | } | ||
5758 | |||
5759 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5463 | { | 5760 | { |
5464 | RegenerateMaptile(); | 5761 | RegenerateMaptile(); |
5465 | 5762 | ||
@@ -5621,7 +5918,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5621 | return true; | 5918 | return true; |
5622 | } | 5919 | } |
5623 | 5920 | ||
5624 | /// <summary> | 5921 | public void StartTimerWatchdog() |
5922 | { | ||
5923 | m_timerWatchdog.Interval = 1000; | ||
5924 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5925 | m_timerWatchdog.AutoReset = true; | ||
5926 | m_timerWatchdog.Start(); | ||
5927 | } | ||
5928 | |||
5929 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5930 | { | ||
5931 | CheckHeartbeat(); | ||
5932 | } | ||
5933 | |||
5625 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5934 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5626 | /// autopilot that moves an avatar to a sit target!. | 5935 | /// autopilot that moves an avatar to a sit target!. |
5627 | /// </summary> | 5936 | /// </summary> |
@@ -5700,6 +6009,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5700 | return m_SpawnPoint - 1; | 6009 | return m_SpawnPoint - 1; |
5701 | } | 6010 | } |
5702 | 6011 | ||
6012 | private void HandleGcCollect(string module, string[] args) | ||
6013 | { | ||
6014 | GC.Collect(); | ||
6015 | } | ||
6016 | |||
5703 | /// <summary> | 6017 | /// <summary> |
5704 | /// Wrappers to get physics modules retrieve assets. | 6018 | /// Wrappers to get physics modules retrieve assets. |
5705 | /// </summary> | 6019 | /// </summary> |