diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 558 |
1 files changed, 433 insertions, 125 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 84fdef0..96e45ed 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 | public bool SeeIntoRegion { get; set; } | 233 | public bool SeeIntoRegion { get; set; } |
234 | 234 | ||
@@ -246,11 +246,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
246 | 246 | ||
247 | protected int m_splitRegionID; | 247 | protected int m_splitRegionID; |
248 | protected Timer m_restartWaitTimer = new Timer(); | 248 | protected Timer m_restartWaitTimer = new Timer(); |
249 | protected Timer m_timerWatchdog = new Timer(); | ||
249 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 250 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
250 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 251 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
251 | protected string m_simulatorVersion = "OpenSimulator Server"; | 252 | protected string m_simulatorVersion = "OpenSimulator Server"; |
252 | protected AgentCircuitManager m_authenticateHandler; | 253 | protected AgentCircuitManager m_authenticateHandler; |
253 | protected SceneCommunicationService m_sceneGridService; | 254 | protected SceneCommunicationService m_sceneGridService; |
255 | protected ISnmpModule m_snmpService = null; | ||
254 | 256 | ||
255 | protected ISimulationDataService m_SimulationDataService; | 257 | protected ISimulationDataService m_SimulationDataService; |
256 | protected IEstateDataService m_EstateDataService; | 258 | protected IEstateDataService m_EstateDataService; |
@@ -313,8 +315,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
313 | private int m_update_presences = 1; // Update scene presence movements | 315 | private int m_update_presences = 1; // Update scene presence movements |
314 | private int m_update_events = 1; | 316 | private int m_update_events = 1; |
315 | private int m_update_backup = 200; | 317 | private int m_update_backup = 200; |
316 | private int m_update_terrain = 50; | 318 | private int m_update_terrain = 1000; |
317 | // private int m_update_land = 1; | 319 | private int m_update_land = 10; |
318 | private int m_update_coarse_locations = 50; | 320 | private int m_update_coarse_locations = 50; |
319 | 321 | ||
320 | private int agentMS; | 322 | private int agentMS; |
@@ -327,13 +329,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
327 | private int backupMS; | 329 | private int backupMS; |
328 | private int terrainMS; | 330 | private int terrainMS; |
329 | private int landMS; | 331 | private int landMS; |
330 | private int spareMS; | ||
331 | 332 | ||
332 | /// <summary> | 333 | /// <summary> |
333 | /// Tick at which the last frame was processed. | 334 | /// Tick at which the last frame was processed. |
334 | /// </summary> | 335 | /// </summary> |
335 | private int m_lastFrameTick; | 336 | private int m_lastFrameTick; |
336 | 337 | ||
338 | public bool CombineRegions = false; | ||
337 | /// <summary> | 339 | /// <summary> |
338 | /// Tick at which the last maintenance run occurred. | 340 | /// Tick at which the last maintenance run occurred. |
339 | /// </summary> | 341 | /// </summary> |
@@ -353,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
353 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 355 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
354 | private volatile bool m_backingup; | 356 | private volatile bool m_backingup; |
355 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 357 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
356 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 358 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
357 | 359 | ||
358 | private string m_defaultScriptEngine; | 360 | private string m_defaultScriptEngine; |
359 | 361 | ||
@@ -362,6 +364,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
362 | /// </summary> | 364 | /// </summary> |
363 | private int m_LastLogin; | 365 | private int m_LastLogin; |
364 | 366 | ||
367 | private int m_lastIncoming; | ||
368 | private int m_lastOutgoing; | ||
369 | private int m_hbRestarts = 0; | ||
370 | |||
371 | |||
365 | /// <summary> | 372 | /// <summary> |
366 | /// Thread that runs the scene loop. | 373 | /// Thread that runs the scene loop. |
367 | /// </summary> | 374 | /// </summary> |
@@ -404,7 +411,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
404 | private volatile bool m_active; | 411 | private volatile bool m_active; |
405 | 412 | ||
406 | // private int m_lastUpdate; | 413 | // private int m_lastUpdate; |
407 | // private bool m_firstHeartbeat = true; | 414 | private bool m_firstHeartbeat = true; |
408 | 415 | ||
409 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 416 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
410 | private bool m_reprioritizationEnabled = true; | 417 | private bool m_reprioritizationEnabled = true; |
@@ -448,6 +455,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
448 | get { return m_sceneGridService; } | 455 | get { return m_sceneGridService; } |
449 | } | 456 | } |
450 | 457 | ||
458 | public ISnmpModule SnmpService | ||
459 | { | ||
460 | get | ||
461 | { | ||
462 | if (m_snmpService == null) | ||
463 | { | ||
464 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
465 | } | ||
466 | |||
467 | return m_snmpService; | ||
468 | } | ||
469 | } | ||
470 | |||
451 | public ISimulationDataService SimulationDataService | 471 | public ISimulationDataService SimulationDataService |
452 | { | 472 | { |
453 | get | 473 | get |
@@ -740,6 +760,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
740 | m_SimulationDataService = simDataService; | 760 | m_SimulationDataService = simDataService; |
741 | m_EstateDataService = estateDataService; | 761 | m_EstateDataService = estateDataService; |
742 | m_regionHandle = RegionInfo.RegionHandle; | 762 | m_regionHandle = RegionInfo.RegionHandle; |
763 | m_lastIncoming = 0; | ||
764 | m_lastOutgoing = 0; | ||
743 | 765 | ||
744 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 766 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
745 | m_asyncSceneObjectDeleter.Enabled = true; | 767 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -833,7 +855,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
833 | 855 | ||
834 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 856 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
835 | 857 | ||
836 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 858 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
837 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 859 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
838 | if (!UseBackup) | 860 | if (!UseBackup) |
839 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 861 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -841,13 +863,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
841 | //Animation states | 863 | //Animation states |
842 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 864 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
843 | 865 | ||
844 | SeeIntoRegion = startupConfig.GetBoolean("see_into_region", true); | ||
845 | 866 | ||
846 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 867 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); |
847 | 868 | ||
848 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | 869 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
849 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | 870 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
850 | |||
851 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 871 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
852 | if (RegionInfo.NonphysPrimMin > 0) | 872 | if (RegionInfo.NonphysPrimMin > 0) |
853 | { | 873 | { |
@@ -867,11 +887,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
867 | } | 887 | } |
868 | 888 | ||
869 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 889 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
890 | |||
870 | if (RegionInfo.PhysPrimMax > 0) | 891 | if (RegionInfo.PhysPrimMax > 0) |
871 | { | 892 | { |
872 | m_maxPhys = RegionInfo.PhysPrimMax; | 893 | m_maxPhys = RegionInfo.PhysPrimMax; |
873 | } | 894 | } |
874 | 895 | ||
896 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
897 | if (RegionInfo.LinksetCapacity > 0) | ||
898 | { | ||
899 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
900 | } | ||
901 | |||
902 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
903 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
904 | |||
875 | // Here, if clamping is requested in either global or | 905 | // Here, if clamping is requested in either global or |
876 | // local config, it will be used | 906 | // local config, it will be used |
877 | // | 907 | // |
@@ -881,13 +911,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
881 | m_clampPrimSize = true; | 911 | m_clampPrimSize = true; |
882 | } | 912 | } |
883 | 913 | ||
884 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 914 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
885 | if (RegionInfo.LinksetCapacity > 0) | ||
886 | { | ||
887 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
888 | } | ||
889 | |||
890 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
891 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 915 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
892 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 916 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
893 | m_dontPersistBefore = | 917 | m_dontPersistBefore = |
@@ -898,11 +922,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
898 | m_persistAfter *= 10000000; | 922 | m_persistAfter *= 10000000; |
899 | 923 | ||
900 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 924 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
901 | 925 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
902 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
903 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
904 | 926 | ||
905 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 927 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
928 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
929 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
906 | 930 | ||
907 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; | 931 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; |
908 | 932 | ||
@@ -947,7 +971,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
947 | 971 | ||
948 | if (grant.Length > 0) | 972 | if (grant.Length > 0) |
949 | { | 973 | { |
950 | foreach (string viewer in grant.Split('|')) | 974 | foreach (string viewer in grant.Split(',')) |
951 | { | 975 | { |
952 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 976 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
953 | } | 977 | } |
@@ -959,7 +983,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
959 | 983 | ||
960 | if (grant.Length > 0) | 984 | if (grant.Length > 0) |
961 | { | 985 | { |
962 | foreach (string viewer in grant.Split('|')) | 986 | foreach (string viewer in grant.Split(',')) |
963 | { | 987 | { |
964 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 988 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
965 | } | 989 | } |
@@ -1019,6 +1043,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1019 | StatsReporter = new SimStatsReporter(this); | 1043 | StatsReporter = new SimStatsReporter(this); |
1020 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1044 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1021 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1045 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1046 | |||
1047 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1022 | } | 1048 | } |
1023 | 1049 | ||
1024 | public Scene(RegionInfo regInfo) : base(regInfo) | 1050 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1314,8 +1340,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1314 | // Stop all client threads. | 1340 | // Stop all client threads. |
1315 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1341 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1316 | 1342 | ||
1317 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1343 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1318 | EventManager.TriggerSceneShuttingDown(this); | 1344 | EventManager.TriggerSceneShuttingDown(this); |
1345 | |||
1346 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1347 | |||
1319 | Backup(false); | 1348 | Backup(false); |
1320 | m_sceneGraph.Close(); | 1349 | m_sceneGraph.Close(); |
1321 | 1350 | ||
@@ -1329,6 +1358,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1329 | // attempt to reference a null or disposed physics scene. | 1358 | // attempt to reference a null or disposed physics scene. |
1330 | if (PhysicsScene != null) | 1359 | if (PhysicsScene != null) |
1331 | { | 1360 | { |
1361 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1332 | PhysicsScene phys = PhysicsScene; | 1362 | PhysicsScene phys = PhysicsScene; |
1333 | // remove the physics engine from both Scene and SceneGraph | 1363 | // remove the physics engine from both Scene and SceneGraph |
1334 | PhysicsScene = null; | 1364 | PhysicsScene = null; |
@@ -1359,11 +1389,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1389 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1360 | if (m_heartbeatThread != null) | 1390 | if (m_heartbeatThread != null) |
1361 | { | 1391 | { |
1392 | m_hbRestarts++; | ||
1393 | if(m_hbRestarts > 10) | ||
1394 | Environment.Exit(1); | ||
1395 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1396 | |||
1397 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1398 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1399 | //proc.EnableRaisingEvents=false; | ||
1400 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1401 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1402 | //proc.Start(); | ||
1403 | //proc.WaitForExit(); | ||
1404 | //Thread.Sleep(1000); | ||
1405 | //Environment.Exit(1); | ||
1362 | m_heartbeatThread.Abort(); | 1406 | m_heartbeatThread.Abort(); |
1407 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1363 | m_heartbeatThread = null; | 1408 | m_heartbeatThread = null; |
1364 | } | 1409 | } |
1365 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1410 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1366 | 1411 | ||
1412 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1413 | |||
1414 | |||
1367 | m_heartbeatThread | 1415 | m_heartbeatThread |
1368 | = Watchdog.StartThread( | 1416 | = Watchdog.StartThread( |
1369 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1417 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1508,16 +1556,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1508 | endFrame = Frame + frames; | 1556 | endFrame = Frame + frames; |
1509 | 1557 | ||
1510 | float physicsFPS = 0f; | 1558 | float physicsFPS = 0f; |
1511 | int previousFrameTick, tmpMS; | 1559 | int tmpMS; |
1512 | int maintc = Util.EnvironmentTickCount(); | 1560 | int previousFrameTick; |
1561 | int maintc; | ||
1562 | int sleepMS; | ||
1563 | int framestart; | ||
1513 | 1564 | ||
1514 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1565 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1515 | { | 1566 | { |
1567 | framestart = Util.EnvironmentTickCount(); | ||
1516 | ++Frame; | 1568 | ++Frame; |
1517 | 1569 | ||
1518 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1570 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1519 | 1571 | ||
1520 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1572 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1521 | 1573 | ||
1522 | try | 1574 | try |
1523 | { | 1575 | { |
@@ -1571,6 +1623,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1571 | m_sceneGraph.UpdatePresences(); | 1623 | m_sceneGraph.UpdatePresences(); |
1572 | 1624 | ||
1573 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1625 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1626 | |||
1574 | 1627 | ||
1575 | // Delete temp-on-rez stuff | 1628 | // Delete temp-on-rez stuff |
1576 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1629 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1652,34 +1705,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1652 | 1705 | ||
1653 | Watchdog.UpdateThread(); | 1706 | Watchdog.UpdateThread(); |
1654 | 1707 | ||
1708 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1709 | |||
1710 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1711 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1712 | StatsReporter.AddFPS(1); | ||
1713 | |||
1714 | StatsReporter.addAgentMS(agentMS); | ||
1715 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1716 | StatsReporter.addOtherMS(otherMS); | ||
1717 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1718 | |||
1655 | previousFrameTick = m_lastFrameTick; | 1719 | previousFrameTick = m_lastFrameTick; |
1656 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1720 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1657 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1721 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1658 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1722 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1659 | 1723 | ||
1724 | m_firstHeartbeat = false; | ||
1725 | |||
1726 | sleepMS = Util.EnvironmentTickCount(); | ||
1727 | |||
1660 | if (tmpMS > 0) | 1728 | if (tmpMS > 0) |
1661 | { | ||
1662 | Thread.Sleep(tmpMS); | 1729 | Thread.Sleep(tmpMS); |
1663 | spareMS += tmpMS; | ||
1664 | } | ||
1665 | 1730 | ||
1666 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | 1731 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1667 | maintc = Util.EnvironmentTickCount(); | 1732 | frameMS = Util.EnvironmentTickCountSubtract(framestart); |
1668 | 1733 | StatsReporter.addSleepMS(sleepMS); | |
1669 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1734 | StatsReporter.addFrameMS(frameMS); |
1670 | 1735 | ||
1671 | // if (Frame%m_update_avatars == 0) | 1736 | // if (Frame%m_update_avatars == 0) |
1672 | // UpdateInWorldTime(); | 1737 | // UpdateInWorldTime(); |
1673 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1674 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1675 | StatsReporter.AddFPS(1); | ||
1676 | 1738 | ||
1677 | StatsReporter.addFrameMS(frameMS); | ||
1678 | StatsReporter.addAgentMS(agentMS); | ||
1679 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1680 | StatsReporter.addOtherMS(otherMS); | ||
1681 | StatsReporter.AddSpareMS(spareMS); | ||
1682 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1683 | 1739 | ||
1684 | // Optionally warn if a frame takes double the amount of time that it should. | 1740 | // Optionally warn if a frame takes double the amount of time that it should. |
1685 | if (DebugUpdates | 1741 | if (DebugUpdates |
@@ -1696,7 +1752,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1696 | public void AddGroupTarget(SceneObjectGroup grp) | 1752 | public void AddGroupTarget(SceneObjectGroup grp) |
1697 | { | 1753 | { |
1698 | lock (m_groupsWithTargets) | 1754 | lock (m_groupsWithTargets) |
1699 | m_groupsWithTargets[grp.UUID] = grp; | 1755 | m_groupsWithTargets[grp.UUID] = 0; |
1700 | } | 1756 | } |
1701 | 1757 | ||
1702 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1758 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1707,18 +1763,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1707 | 1763 | ||
1708 | private void CheckAtTargets() | 1764 | private void CheckAtTargets() |
1709 | { | 1765 | { |
1710 | List<SceneObjectGroup> objs = null; | 1766 | List<UUID> objs = null; |
1711 | 1767 | ||
1712 | lock (m_groupsWithTargets) | 1768 | lock (m_groupsWithTargets) |
1713 | { | 1769 | { |
1714 | if (m_groupsWithTargets.Count != 0) | 1770 | if (m_groupsWithTargets.Count != 0) |
1715 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1771 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1716 | } | 1772 | } |
1717 | 1773 | ||
1718 | if (objs != null) | 1774 | if (objs != null) |
1719 | { | 1775 | { |
1720 | foreach (SceneObjectGroup entry in objs) | 1776 | foreach (UUID entry in objs) |
1721 | entry.checkAtTargets(); | 1777 | { |
1778 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1779 | if (grp == null) | ||
1780 | m_groupsWithTargets.Remove(entry); | ||
1781 | else | ||
1782 | grp.checkAtTargets(); | ||
1783 | } | ||
1722 | } | 1784 | } |
1723 | } | 1785 | } |
1724 | 1786 | ||
@@ -1797,7 +1859,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1797 | msg.fromAgentName = "Server"; | 1859 | msg.fromAgentName = "Server"; |
1798 | msg.dialog = (byte)19; // Object msg | 1860 | msg.dialog = (byte)19; // Object msg |
1799 | msg.fromGroup = false; | 1861 | msg.fromGroup = false; |
1800 | msg.offline = (byte)0; | 1862 | msg.offline = (byte)1; |
1801 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1863 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1802 | msg.Position = Vector3.Zero; | 1864 | msg.Position = Vector3.Zero; |
1803 | msg.RegionID = RegionInfo.RegionID.Guid; | 1865 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2026,7 +2088,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2026 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2088 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
2027 | } | 2089 | } |
2028 | 2090 | ||
2029 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2091 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
2030 | { | 2092 | { |
2031 | if (PhysicsScene == null) | 2093 | if (PhysicsScene == null) |
2032 | return null; | 2094 | return null; |
@@ -2048,14 +2110,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2048 | /// <returns></returns> | 2110 | /// <returns></returns> |
2049 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2111 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2050 | { | 2112 | { |
2113 | |||
2114 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2115 | Vector3 wpos = Vector3.Zero; | ||
2116 | // Check for water surface intersection from above | ||
2117 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2118 | { | ||
2119 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2120 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2121 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2122 | wpos.Z = wheight; | ||
2123 | } | ||
2124 | |||
2051 | Vector3 pos = Vector3.Zero; | 2125 | Vector3 pos = Vector3.Zero; |
2052 | if (RayEndIsIntersection == (byte)1) | 2126 | if (RayEndIsIntersection == (byte)1) |
2053 | { | 2127 | { |
2054 | pos = RayEnd; | 2128 | pos = RayEnd; |
2055 | return pos; | ||
2056 | } | 2129 | } |
2057 | 2130 | else if (RayTargetID != UUID.Zero) | |
2058 | if (RayTargetID != UUID.Zero) | ||
2059 | { | 2131 | { |
2060 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2132 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2061 | 2133 | ||
@@ -2077,7 +2149,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2077 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2149 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2078 | 2150 | ||
2079 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2151 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2080 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2152 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2081 | float ScaleOffset = 0.5f; | 2153 | float ScaleOffset = 0.5f; |
2082 | 2154 | ||
2083 | // If we hit something | 2155 | // If we hit something |
@@ -2100,13 +2172,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2100 | //pos.Z -= 0.25F; | 2172 | //pos.Z -= 0.25F; |
2101 | 2173 | ||
2102 | } | 2174 | } |
2103 | |||
2104 | return pos; | ||
2105 | } | 2175 | } |
2106 | else | 2176 | else |
2107 | { | 2177 | { |
2108 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2178 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2109 | |||
2110 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2179 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2111 | 2180 | ||
2112 | // Un-comment the following line to print the raytrace results to the console. | 2181 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2115,13 +2184,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2115 | if (ei.HitTF) | 2184 | if (ei.HitTF) |
2116 | { | 2185 | { |
2117 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2186 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2118 | } else | 2187 | } |
2188 | else | ||
2119 | { | 2189 | { |
2120 | // fall back to our stupid functionality | 2190 | // fall back to our stupid functionality |
2121 | pos = RayEnd; | 2191 | pos = RayEnd; |
2122 | } | 2192 | } |
2123 | |||
2124 | return pos; | ||
2125 | } | 2193 | } |
2126 | } | 2194 | } |
2127 | else | 2195 | else |
@@ -2132,8 +2200,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2132 | //increase height so its above the ground. | 2200 | //increase height so its above the ground. |
2133 | //should be getting the normal of the ground at the rez point and using that? | 2201 | //should be getting the normal of the ground at the rez point and using that? |
2134 | pos.Z += scale.Z / 2f; | 2202 | pos.Z += scale.Z / 2f; |
2135 | return pos; | 2203 | // return pos; |
2136 | } | 2204 | } |
2205 | |||
2206 | // check against posible water intercept | ||
2207 | if (wpos.Z > pos.Z) pos = wpos; | ||
2208 | return pos; | ||
2137 | } | 2209 | } |
2138 | 2210 | ||
2139 | 2211 | ||
@@ -2224,12 +2296,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2224 | { | 2296 | { |
2225 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2297 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2226 | { | 2298 | { |
2299 | sceneObject.IsDeleted = false; | ||
2227 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2300 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2228 | return true; | 2301 | return true; |
2229 | } | 2302 | } |
2230 | 2303 | ||
2231 | return false; | 2304 | return false; |
2232 | |||
2233 | } | 2305 | } |
2234 | 2306 | ||
2235 | /// <summary> | 2307 | /// <summary> |
@@ -2321,6 +2393,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2321 | /// </summary> | 2393 | /// </summary> |
2322 | public void DeleteAllSceneObjects() | 2394 | public void DeleteAllSceneObjects() |
2323 | { | 2395 | { |
2396 | DeleteAllSceneObjects(false); | ||
2397 | } | ||
2398 | |||
2399 | /// <summary> | ||
2400 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2401 | /// </summary> | ||
2402 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2403 | { | ||
2404 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2324 | lock (Entities) | 2405 | lock (Entities) |
2325 | { | 2406 | { |
2326 | EntityBase[] entities = Entities.GetEntities(); | 2407 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2329,11 +2410,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2329 | if (e is SceneObjectGroup) | 2410 | if (e is SceneObjectGroup) |
2330 | { | 2411 | { |
2331 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2412 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2332 | if (!sog.IsAttachment) | 2413 | if (sog != null && !sog.IsAttachment) |
2333 | DeleteSceneObject((SceneObjectGroup)e, false); | 2414 | { |
2415 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2416 | { | ||
2417 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2418 | } | ||
2419 | else | ||
2420 | { | ||
2421 | toReturn.Add((SceneObjectGroup)e); | ||
2422 | } | ||
2423 | } | ||
2334 | } | 2424 | } |
2335 | } | 2425 | } |
2336 | } | 2426 | } |
2427 | if (toReturn.Count > 0) | ||
2428 | { | ||
2429 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2430 | } | ||
2337 | } | 2431 | } |
2338 | 2432 | ||
2339 | /// <summary> | 2433 | /// <summary> |
@@ -2364,6 +2458,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2364 | else | 2458 | else |
2365 | group.StopScriptInstances(); | 2459 | group.StopScriptInstances(); |
2366 | 2460 | ||
2461 | List<UUID> avatars = group.GetSittingAvatars(); | ||
2462 | foreach (UUID av in avatars) | ||
2463 | { | ||
2464 | ScenePresence p = GetScenePresence(av); | ||
2465 | if (p != null) | ||
2466 | p.StandUp(); | ||
2467 | } | ||
2468 | |||
2367 | SceneObjectPart[] partList = group.Parts; | 2469 | SceneObjectPart[] partList = group.Parts; |
2368 | 2470 | ||
2369 | foreach (SceneObjectPart part in partList) | 2471 | foreach (SceneObjectPart part in partList) |
@@ -2391,6 +2493,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2391 | } | 2493 | } |
2392 | 2494 | ||
2393 | group.DeleteGroupFromScene(silent); | 2495 | group.DeleteGroupFromScene(silent); |
2496 | if (!silent) | ||
2497 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2394 | 2498 | ||
2395 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2499 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2396 | } | 2500 | } |
@@ -2680,7 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2680 | // If the user is banned, we won't let any of their objects | 2784 | // If the user is banned, we won't let any of their objects |
2681 | // enter. Period. | 2785 | // enter. Period. |
2682 | // | 2786 | // |
2683 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2787 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2684 | { | 2788 | { |
2685 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2789 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2686 | return false; | 2790 | return false; |
@@ -2735,6 +2839,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2735 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2839 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2736 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2840 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2737 | { | 2841 | { |
2842 | if (sceneObject.OwnerID == UUID.Zero) | ||
2843 | { | ||
2844 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2845 | return false; | ||
2846 | } | ||
2847 | |||
2848 | // If the user is banned, we won't let any of their objects | ||
2849 | // enter. Period. | ||
2850 | // | ||
2851 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2852 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2853 | { | ||
2854 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2855 | |||
2856 | return false; | ||
2857 | } | ||
2858 | |||
2738 | // Force allocation of new LocalId | 2859 | // Force allocation of new LocalId |
2739 | // | 2860 | // |
2740 | SceneObjectPart[] parts = sceneObject.Parts; | 2861 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2771,16 +2892,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2771 | // information that this is due to a teleport/border cross rather than an ordinary attachment. | 2892 | // information that this is due to a teleport/border cross rather than an ordinary attachment. |
2772 | // We currently do this in Scene.MakeRootAgent() instead. | 2893 | // We currently do this in Scene.MakeRootAgent() instead. |
2773 | if (AttachmentsModule != null) | 2894 | if (AttachmentsModule != null) |
2774 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); | 2895 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); |
2775 | } | 2896 | } |
2776 | else | 2897 | else |
2777 | { | 2898 | { |
2899 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2778 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2900 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2779 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2901 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2780 | } | 2902 | } |
2903 | if (sceneObject.OwnerID == UUID.Zero) | ||
2904 | { | ||
2905 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2906 | return false; | ||
2907 | } | ||
2781 | } | 2908 | } |
2782 | else | 2909 | else |
2783 | { | 2910 | { |
2911 | if (sceneObject.OwnerID == UUID.Zero) | ||
2912 | { | ||
2913 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2914 | return false; | ||
2915 | } | ||
2784 | AddRestoredSceneObject(sceneObject, true, false); | 2916 | AddRestoredSceneObject(sceneObject, true, false); |
2785 | } | 2917 | } |
2786 | 2918 | ||
@@ -2797,6 +2929,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2797 | return 2; // StateSource.PrimCrossing | 2929 | return 2; // StateSource.PrimCrossing |
2798 | } | 2930 | } |
2799 | 2931 | ||
2932 | public int GetUserFlags(UUID user) | ||
2933 | { | ||
2934 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2935 | /* | ||
2936 | ScenePresence sp; | ||
2937 | if (TryGetScenePresence(user, out sp)) | ||
2938 | { | ||
2939 | return sp.UserFlags; | ||
2940 | } | ||
2941 | else | ||
2942 | { | ||
2943 | */ | ||
2944 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2945 | if (uac == null) | ||
2946 | return 0; | ||
2947 | return uac.UserFlags; | ||
2948 | //} | ||
2949 | } | ||
2800 | #endregion | 2950 | #endregion |
2801 | 2951 | ||
2802 | #region Add/Remove Avatar Methods | 2952 | #region Add/Remove Avatar Methods |
@@ -2829,7 +2979,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2829 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2979 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2830 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2980 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2831 | 2981 | ||
2832 | // CheckHeartbeat(); | 2982 | CheckHeartbeat(); |
2833 | 2983 | ||
2834 | sp = GetScenePresence(client.AgentId); | 2984 | sp = GetScenePresence(client.AgentId); |
2835 | 2985 | ||
@@ -2847,6 +2997,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2847 | SubscribeToClientEvents(client); | 2997 | SubscribeToClientEvents(client); |
2848 | 2998 | ||
2849 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | 2999 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
3000 | InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
3001 | if (cof == null) | ||
3002 | sp.COF = UUID.Zero; | ||
3003 | else | ||
3004 | sp.COF = cof.ID; | ||
3005 | |||
3006 | m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); | ||
2850 | m_eventManager.TriggerOnNewPresence(sp); | 3007 | m_eventManager.TriggerOnNewPresence(sp); |
2851 | 3008 | ||
2852 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | 3009 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; |
@@ -2961,19 +3118,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2961 | // and the scene presence and the client, if they exist | 3118 | // and the scene presence and the client, if they exist |
2962 | try | 3119 | try |
2963 | { | 3120 | { |
2964 | // We need to wait for the client to make UDP contact first. | 3121 | ScenePresence sp = GetScenePresence(agentID); |
2965 | // It's the UDP contact that creates the scene presence | 3122 | |
2966 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2967 | if (sp != null) | 3123 | if (sp != null) |
2968 | { | 3124 | { |
2969 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3125 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2970 | |||
2971 | sp.ControllingClient.Close(); | 3126 | sp.ControllingClient.Close(); |
2972 | } | 3127 | } |
2973 | else | 3128 | |
2974 | { | ||
2975 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2976 | } | ||
2977 | // BANG! SLASH! | 3129 | // BANG! SLASH! |
2978 | m_authenticateHandler.RemoveCircuit(agentID); | 3130 | m_authenticateHandler.RemoveCircuit(agentID); |
2979 | 3131 | ||
@@ -3018,6 +3170,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3018 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3170 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
3019 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3171 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
3020 | 3172 | ||
3173 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3174 | |||
3021 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3175 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3022 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3176 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3023 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3177 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3074,6 +3228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3074 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3228 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3075 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3229 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3076 | client.OnCopyInventoryItem += CopyInventoryItem; | 3230 | client.OnCopyInventoryItem += CopyInventoryItem; |
3231 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3077 | client.OnMoveInventoryItem += MoveInventoryItem; | 3232 | client.OnMoveInventoryItem += MoveInventoryItem; |
3078 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3233 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3079 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3234 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3143,6 +3298,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3143 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3298 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3144 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3299 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3145 | 3300 | ||
3301 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3302 | |||
3146 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3303 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3147 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3304 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3148 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3305 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3448,7 +3605,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3448 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 3605 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3449 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 3606 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3450 | if (closeChildAgents && CapsModule != null) | 3607 | if (closeChildAgents && CapsModule != null) |
3451 | CapsModule.RemoveCaps(agentID); | 3608 | CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); |
3452 | 3609 | ||
3453 | if (closeChildAgents && !isChildAgent) | 3610 | if (closeChildAgents && !isChildAgent) |
3454 | { | 3611 | { |
@@ -3481,6 +3638,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3481 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3638 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3482 | if (AgentTransactionsModule != null) | 3639 | if (AgentTransactionsModule != null) |
3483 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3640 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3641 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3484 | } | 3642 | } |
3485 | catch (Exception e) | 3643 | catch (Exception e) |
3486 | { | 3644 | { |
@@ -3674,15 +3832,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3674 | agent.firstname, agent.lastname, agent.Viewer); | 3832 | agent.firstname, agent.lastname, agent.Viewer); |
3675 | reason = "Access denied, your viewer is banned by the region owner"; | 3833 | reason = "Access denied, your viewer is banned by the region owner"; |
3676 | return false; | 3834 | return false; |
3677 | } | 3835 | } |
3678 | 3836 | ||
3679 | ILandObject land; | 3837 | ScenePresence sp = GetScenePresence(agent.AgentID); |
3680 | 3838 | ||
3681 | lock (agent) | 3839 | // If we have noo presence here or if that presence is a zombie root |
3840 | // presence that will be kicled, we need a new CAPS object. | ||
3841 | if (sp == null || (sp != null && !sp.IsChildAgent)) | ||
3682 | { | 3842 | { |
3683 | ScenePresence sp = GetScenePresence(agent.AgentID); | 3843 | if (CapsModule != null) |
3684 | 3844 | { | |
3685 | if (sp != null && !sp.IsChildAgent) | 3845 | lock (agent) |
3846 | { | ||
3847 | CapsModule.SetAgentCapsSeeds(agent); | ||
3848 | CapsModule.CreateCaps(agent.AgentID, agent.circuitcode); | ||
3849 | } | ||
3850 | } | ||
3851 | } | ||
3852 | |||
3853 | if (sp != null) | ||
3854 | { | ||
3855 | if (!sp.IsChildAgent) | ||
3686 | { | 3856 | { |
3687 | // We have a zombie from a crashed session. | 3857 | // We have a zombie from a crashed session. |
3688 | // Or the same user is trying to be root twice here, won't work. | 3858 | // Or the same user is trying to be root twice here, won't work. |
@@ -3692,29 +3862,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3692 | sp.Name, sp.UUID, RegionInfo.RegionName); | 3862 | sp.Name, sp.UUID, RegionInfo.RegionName); |
3693 | 3863 | ||
3694 | if (sp.ControllingClient != null) | 3864 | if (sp.ControllingClient != null) |
3695 | sp.ControllingClient.Close(true); | 3865 | sp.ControllingClient.Close(true, true); |
3696 | 3866 | ||
3697 | sp = null; | 3867 | sp = null; |
3698 | } | 3868 | } |
3869 | } | ||
3699 | 3870 | ||
3871 | lock (agent) | ||
3872 | { | ||
3700 | // Optimistic: add or update the circuit data with the new agent circuit data and teleport flags. | 3873 | // Optimistic: add or update the circuit data with the new agent circuit data and teleport flags. |
3701 | // We need the circuit data here for some of the subsequent checks. (groups, for example) | 3874 | // We need the circuit data here for some of the subsequent checks. (groups, for example) |
3702 | // If the checks fail, we remove the circuit. | 3875 | // If the checks fail, we remove the circuit. |
3703 | agent.teleportFlags = teleportFlags; | 3876 | agent.teleportFlags = teleportFlags; |
3704 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3877 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3705 | 3878 | ||
3706 | land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3707 | |||
3708 | // On login test land permisions | 3879 | // On login test land permisions |
3709 | if (vialogin) | 3880 | if (vialogin) |
3710 | { | 3881 | { |
3711 | if (land != null && !TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | 3882 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3883 | if (cache != null) | ||
3884 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3885 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3712 | { | 3886 | { |
3887 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3713 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3888 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); |
3714 | return false; | 3889 | return false; |
3715 | } | 3890 | } |
3716 | } | 3891 | } |
3717 | 3892 | ||
3718 | if (sp == null) // We don't have an [child] agent here already | 3893 | if (sp == null) // We don't have an [child] agent here already |
3719 | { | 3894 | { |
3720 | if (requirePresenceLookup) | 3895 | if (requirePresenceLookup) |
@@ -3736,7 +3911,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3736 | return false; | 3911 | return false; |
3737 | } | 3912 | } |
3738 | } | 3913 | } |
3739 | 3914 | ||
3740 | try | 3915 | try |
3741 | { | 3916 | { |
3742 | if (!AuthorizeUser(agent, SeeIntoRegion, out reason)) | 3917 | if (!AuthorizeUser(agent, SeeIntoRegion, out reason)) |
@@ -3753,32 +3928,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3753 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3928 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); |
3754 | return false; | 3929 | return false; |
3755 | } | 3930 | } |
3756 | 3931 | ||
3757 | m_log.InfoFormat( | 3932 | m_log.InfoFormat( |
3758 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 3933 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3759 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3934 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3760 | agent.AgentID, agent.circuitcode); | 3935 | agent.AgentID, agent.circuitcode); |
3761 | 3936 | ||
3762 | if (CapsModule != null) | ||
3763 | { | ||
3764 | CapsModule.SetAgentCapsSeeds(agent); | ||
3765 | CapsModule.CreateCaps(agent.AgentID); | ||
3766 | } | ||
3767 | } | 3937 | } |
3768 | else | 3938 | else |
3769 | { | 3939 | { |
3770 | // Let the SP know how we got here. This has a lot of interesting | 3940 | // Let the SP know how we got here. This has a lot of interesting |
3771 | // uses down the line. | 3941 | // uses down the line. |
3772 | sp.TeleportFlags = (TPFlags)teleportFlags; | 3942 | sp.TeleportFlags = (TPFlags)teleportFlags; |
3773 | 3943 | ||
3774 | if (sp.IsChildAgent) | 3944 | if (sp.IsChildAgent) |
3775 | { | 3945 | { |
3776 | m_log.DebugFormat( | 3946 | m_log.DebugFormat( |
3777 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3947 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
3778 | agent.AgentID, RegionInfo.RegionName); | 3948 | agent.AgentID, RegionInfo.RegionName); |
3779 | 3949 | ||
3780 | sp.AdjustKnownSeeds(); | 3950 | sp.AdjustKnownSeeds(); |
3781 | 3951 | ||
3782 | if (CapsModule != null) | 3952 | if (CapsModule != null) |
3783 | CapsModule.SetAgentCapsSeeds(agent); | 3953 | CapsModule.SetAgentCapsSeeds(agent); |
3784 | } | 3954 | } |
@@ -3790,6 +3960,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3790 | CacheUserName(null, agent); | 3960 | CacheUserName(null, agent); |
3791 | } | 3961 | } |
3792 | 3962 | ||
3963 | if (CapsModule != null) | ||
3964 | { | ||
3965 | CapsModule.ActivateCaps(agent.circuitcode); | ||
3966 | } | ||
3967 | |||
3793 | if (vialogin) | 3968 | if (vialogin) |
3794 | { | 3969 | { |
3795 | // CleanDroppedAttachments(); | 3970 | // CleanDroppedAttachments(); |
@@ -3881,6 +4056,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3881 | } | 4056 | } |
3882 | 4057 | ||
3883 | // Honor parcel landing type and position. | 4058 | // Honor parcel landing type and position. |
4059 | /* | ||
4060 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3884 | if (land != null) | 4061 | if (land != null) |
3885 | { | 4062 | { |
3886 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4063 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3888,6 +4065,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3888 | agent.startpos = land.LandData.UserLocation; | 4065 | agent.startpos = land.LandData.UserLocation; |
3889 | } | 4066 | } |
3890 | } | 4067 | } |
4068 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3891 | } | 4069 | } |
3892 | 4070 | ||
3893 | return true; | 4071 | return true; |
@@ -3985,7 +4163,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3985 | 4163 | ||
3986 | if (!m_strictAccessControl) return true; | 4164 | if (!m_strictAccessControl) return true; |
3987 | if (Permissions.IsGod(agent.AgentID)) return true; | 4165 | if (Permissions.IsGod(agent.AgentID)) return true; |
3988 | 4166 | ||
3989 | if (AuthorizationService != null) | 4167 | if (AuthorizationService != null) |
3990 | { | 4168 | { |
3991 | if (!AuthorizationService.IsAuthorizedForRegion( | 4169 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -4000,7 +4178,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4000 | 4178 | ||
4001 | if (RegionInfo.EstateSettings != null) | 4179 | if (RegionInfo.EstateSettings != null) |
4002 | { | 4180 | { |
4003 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4181 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
4004 | { | 4182 | { |
4005 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4183 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
4006 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4184 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4195,6 +4373,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4195 | m_log.DebugFormat( | 4373 | m_log.DebugFormat( |
4196 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4374 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4197 | 4375 | ||
4376 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4377 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4378 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4379 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4380 | { | ||
4381 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4382 | return false; | ||
4383 | } | ||
4384 | |||
4198 | // TODO: This check should probably be in QueryAccess(). | 4385 | // TODO: This check should probably be in QueryAccess(). |
4199 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4386 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4200 | if (nearestParcel == null) | 4387 | if (nearestParcel == null) |
@@ -4283,7 +4470,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4283 | /// <param name='agentID'></param> | 4470 | /// <param name='agentID'></param> |
4284 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4471 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4285 | { | 4472 | { |
4286 | int ntimes = 20; | 4473 | int ntimes = 30; |
4287 | ScenePresence sp = null; | 4474 | ScenePresence sp = null; |
4288 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4475 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4289 | Thread.Sleep(1000); | 4476 | Thread.Sleep(1000); |
@@ -4328,6 +4515,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4328 | return false; | 4515 | return false; |
4329 | } | 4516 | } |
4330 | 4517 | ||
4518 | public bool IncomingCloseAgent(UUID agentID) | ||
4519 | { | ||
4520 | return IncomingCloseAgent(agentID, false); | ||
4521 | } | ||
4522 | |||
4523 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4524 | { | ||
4525 | return IncomingCloseAgent(agentID, true); | ||
4526 | } | ||
4527 | |||
4331 | /// <summary> | 4528 | /// <summary> |
4332 | /// Tell a single agent to disconnect from the region. | 4529 | /// Tell a single agent to disconnect from the region. |
4333 | /// </summary> | 4530 | /// </summary> |
@@ -4342,7 +4539,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4342 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4539 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4343 | if (presence != null) | 4540 | if (presence != null) |
4344 | { | 4541 | { |
4345 | presence.ControllingClient.Close(force); | 4542 | presence.ControllingClient.Close(force, force); |
4346 | return true; | 4543 | return true; |
4347 | } | 4544 | } |
4348 | 4545 | ||
@@ -4960,7 +5157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4960 | { | 5157 | { |
4961 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5158 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
4962 | { | 5159 | { |
4963 | if (grp.RootPart.Expires <= DateTime.Now) | 5160 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
4964 | DeleteSceneObject(grp, false); | 5161 | DeleteSceneObject(grp, false); |
4965 | } | 5162 | } |
4966 | } | 5163 | } |
@@ -4974,35 +5171,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4974 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5171 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4975 | } | 5172 | } |
4976 | 5173 | ||
4977 | public int GetHealth() | 5174 | public int GetHealth(out int flags, out string message) |
4978 | { | 5175 | { |
4979 | // Returns: | 5176 | // Returns: |
4980 | // 1 = sim is up and accepting http requests. The heartbeat has | 5177 | // 1 = sim is up and accepting http requests. The heartbeat has |
4981 | // stopped and the sim is probably locked up, but a remote | 5178 | // stopped and the sim is probably locked up, but a remote |
4982 | // admin restart may succeed | 5179 | // admin restart may succeed |
4983 | // | 5180 | // |
4984 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5181 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4985 | // usable for people within and logins _may_ work | 5182 | // usable for people within |
5183 | // | ||
5184 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5185 | // unstable and will not accept new logins | ||
4986 | // | 5186 | // |
4987 | // 3 = We have seen a new user enter within the past 4 minutes | 5187 | // 4 = Sim is up and both packet threads are running. Sim is |
5188 | // likely usable | ||
5189 | // | ||
5190 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4988 | // which can be seen as positive confirmation of sim health | 5191 | // which can be seen as positive confirmation of sim health |
4989 | // | 5192 | // |
5193 | |||
5194 | flags = 0; | ||
5195 | message = String.Empty; | ||
5196 | |||
5197 | CheckHeartbeat(); | ||
5198 | |||
5199 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5200 | { | ||
5201 | // We're still starting | ||
5202 | // 0 means "in startup", it can't happen another way, since | ||
5203 | // to get here, we must be able to accept http connections | ||
5204 | return 0; | ||
5205 | } | ||
5206 | |||
4990 | int health=1; // Start at 1, means we're up | 5207 | int health=1; // Start at 1, means we're up |
4991 | 5208 | ||
4992 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5209 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4993 | health += 1; | 5210 | { |
5211 | health+=1; | ||
5212 | flags |= 1; | ||
5213 | } | ||
5214 | |||
5215 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5216 | { | ||
5217 | health+=1; | ||
5218 | flags |= 2; | ||
5219 | } | ||
5220 | |||
5221 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5222 | { | ||
5223 | health+=1; | ||
5224 | flags |= 4; | ||
5225 | } | ||
4994 | else | 5226 | else |
5227 | { | ||
5228 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5229 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5230 | proc.EnableRaisingEvents=false; | ||
5231 | proc.StartInfo.FileName = "/bin/kill"; | ||
5232 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5233 | proc.Start(); | ||
5234 | proc.WaitForExit(); | ||
5235 | Thread.Sleep(1000); | ||
5236 | Environment.Exit(1); | ||
5237 | } | ||
5238 | |||
5239 | if (flags != 7) | ||
4995 | return health; | 5240 | return health; |
4996 | 5241 | ||
4997 | // A login in the last 4 mins? We can't be doing too badly | 5242 | // A login in the last 4 mins? We can't be doing too badly |
4998 | // | 5243 | // |
4999 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5244 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
5000 | health++; | 5245 | health++; |
5001 | else | 5246 | else |
5002 | return health; | 5247 | return health; |
5003 | 5248 | ||
5004 | // CheckHeartbeat(); | ||
5005 | |||
5006 | return health; | 5249 | return health; |
5007 | } | 5250 | } |
5008 | 5251 | ||
@@ -5090,7 +5333,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5090 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5333 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5091 | if (wasUsingPhysics) | 5334 | if (wasUsingPhysics) |
5092 | { | 5335 | { |
5093 | 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 | 5336 | 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 |
5094 | } | 5337 | } |
5095 | } | 5338 | } |
5096 | 5339 | ||
@@ -5189,14 +5432,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5189 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5432 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5190 | } | 5433 | } |
5191 | 5434 | ||
5192 | // private void CheckHeartbeat() | 5435 | private void CheckHeartbeat() |
5193 | // { | 5436 | { |
5194 | // if (m_firstHeartbeat) | 5437 | if (m_firstHeartbeat) |
5195 | // return; | 5438 | return; |
5196 | // | 5439 | |
5197 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5440 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5198 | // StartTimer(); | 5441 | Start(); |
5199 | // } | 5442 | } |
5200 | 5443 | ||
5201 | public override ISceneObject DeserializeObject(string representation) | 5444 | public override ISceneObject DeserializeObject(string representation) |
5202 | { | 5445 | { |
@@ -5254,7 +5497,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5254 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | 5497 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); |
5255 | 5498 | ||
5256 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | 5499 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); |
5257 | 5500 | ||
5258 | return nearestRegionEdgePoint; | 5501 | return nearestRegionEdgePoint; |
5259 | } | 5502 | } |
5260 | 5503 | ||
@@ -5508,7 +5751,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5508 | mapModule.GenerateMaptile(); | 5751 | mapModule.GenerateMaptile(); |
5509 | } | 5752 | } |
5510 | 5753 | ||
5511 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5754 | // public void CleanDroppedAttachments() |
5755 | // { | ||
5756 | // List<SceneObjectGroup> objectsToDelete = | ||
5757 | // new List<SceneObjectGroup>(); | ||
5758 | // | ||
5759 | // lock (m_cleaningAttachments) | ||
5760 | // { | ||
5761 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5762 | // { | ||
5763 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5764 | // { | ||
5765 | // UUID agentID = grp.OwnerID; | ||
5766 | // if (agentID == UUID.Zero) | ||
5767 | // { | ||
5768 | // objectsToDelete.Add(grp); | ||
5769 | // return; | ||
5770 | // } | ||
5771 | // | ||
5772 | // ScenePresence sp = GetScenePresence(agentID); | ||
5773 | // if (sp == null) | ||
5774 | // { | ||
5775 | // objectsToDelete.Add(grp); | ||
5776 | // return; | ||
5777 | // } | ||
5778 | // } | ||
5779 | // }); | ||
5780 | // } | ||
5781 | // | ||
5782 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5783 | // { | ||
5784 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5785 | // DeleteSceneObject(grp, true); | ||
5786 | // } | ||
5787 | // } | ||
5788 | |||
5789 | public void ThreadAlive(int threadCode) | ||
5790 | { | ||
5791 | switch(threadCode) | ||
5792 | { | ||
5793 | case 1: // Incoming | ||
5794 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5795 | break; | ||
5796 | case 2: // Incoming | ||
5797 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5798 | break; | ||
5799 | } | ||
5800 | } | ||
5801 | |||
5802 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5512 | { | 5803 | { |
5513 | RegenerateMaptile(); | 5804 | RegenerateMaptile(); |
5514 | 5805 | ||
@@ -5670,7 +5961,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5670 | return true; | 5961 | return true; |
5671 | } | 5962 | } |
5672 | 5963 | ||
5673 | /// <summary> | 5964 | public void StartTimerWatchdog() |
5965 | { | ||
5966 | m_timerWatchdog.Interval = 1000; | ||
5967 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5968 | m_timerWatchdog.AutoReset = true; | ||
5969 | m_timerWatchdog.Start(); | ||
5970 | } | ||
5971 | |||
5972 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5973 | { | ||
5974 | CheckHeartbeat(); | ||
5975 | } | ||
5976 | |||
5674 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5977 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5675 | /// autopilot that moves an avatar to a sit target!. | 5978 | /// autopilot that moves an avatar to a sit target!. |
5676 | /// </summary> | 5979 | /// </summary> |
@@ -5749,6 +6052,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5749 | return m_SpawnPoint - 1; | 6052 | return m_SpawnPoint - 1; |
5750 | } | 6053 | } |
5751 | 6054 | ||
6055 | private void HandleGcCollect(string module, string[] args) | ||
6056 | { | ||
6057 | GC.Collect(); | ||
6058 | } | ||
6059 | |||
5752 | /// <summary> | 6060 | /// <summary> |
5753 | /// Wrappers to get physics modules retrieve assets. | 6061 | /// Wrappers to get physics modules retrieve assets. |
5754 | /// </summary> | 6062 | /// </summary> |