aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs520
1 files changed, 412 insertions, 108 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c3110a2..55766cf 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
@@ -741,6 +761,8 @@ namespace OpenSim.Region.Framework.Scenes
741 m_SimulationDataService = simDataService; 761 m_SimulationDataService = simDataService;
742 m_EstateDataService = estateDataService; 762 m_EstateDataService = estateDataService;
743 m_regionHandle = RegionInfo.RegionHandle; 763 m_regionHandle = RegionInfo.RegionHandle;
764 m_lastIncoming = 0;
765 m_lastOutgoing = 0;
744 766
745 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 767 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
746 m_asyncSceneObjectDeleter.Enabled = true; 768 m_asyncSceneObjectDeleter.Enabled = true;
@@ -834,7 +856,7 @@ namespace OpenSim.Region.Framework.Scenes
834 856
835 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 857 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
836 858
837 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); 859 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
838 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); 860 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
839 if (!UseBackup) 861 if (!UseBackup)
840 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); 862 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
@@ -846,9 +868,8 @@ namespace OpenSim.Region.Framework.Scenes
846 868
847 MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); 869 MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20);
848 870
849 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); 871 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
850 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); 872 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
851
852 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); 873 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
853 if (RegionInfo.NonphysPrimMin > 0) 874 if (RegionInfo.NonphysPrimMin > 0)
854 { 875 {
@@ -868,11 +889,21 @@ namespace OpenSim.Region.Framework.Scenes
868 } 889 }
869 890
870 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 891 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
892
871 if (RegionInfo.PhysPrimMax > 0) 893 if (RegionInfo.PhysPrimMax > 0)
872 { 894 {
873 m_maxPhys = RegionInfo.PhysPrimMax; 895 m_maxPhys = RegionInfo.PhysPrimMax;
874 } 896 }
875 897
898 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
899 if (RegionInfo.LinksetCapacity > 0)
900 {
901 m_linksetCapacity = RegionInfo.LinksetCapacity;
902 }
903
904 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
905 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
906
876 // Here, if clamping is requested in either global or 907 // Here, if clamping is requested in either global or
877 // local config, it will be used 908 // local config, it will be used
878 // 909 //
@@ -882,13 +913,7 @@ namespace OpenSim.Region.Framework.Scenes
882 m_clampPrimSize = true; 913 m_clampPrimSize = true;
883 } 914 }
884 915
885 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 916 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
886 if (RegionInfo.LinksetCapacity > 0)
887 {
888 m_linksetCapacity = RegionInfo.LinksetCapacity;
889 }
890
891 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete);
892 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 917 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
893 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 918 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
894 m_dontPersistBefore = 919 m_dontPersistBefore =
@@ -899,11 +924,11 @@ namespace OpenSim.Region.Framework.Scenes
899 m_persistAfter *= 10000000; 924 m_persistAfter *= 10000000;
900 925
901 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 926 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
902 927 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
903 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
904 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
905 928
906 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 929 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
930 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
931 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
907 932
908 string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; 933 string[] possibleMapConfigSections = new string[] { "Map", "Startup" };
909 934
@@ -948,7 +973,7 @@ namespace OpenSim.Region.Framework.Scenes
948 973
949 if (grant.Length > 0) 974 if (grant.Length > 0)
950 { 975 {
951 foreach (string viewer in grant.Split('|')) 976 foreach (string viewer in grant.Split(','))
952 { 977 {
953 m_AllowedViewers.Add(viewer.Trim().ToLower()); 978 m_AllowedViewers.Add(viewer.Trim().ToLower());
954 } 979 }
@@ -960,7 +985,7 @@ namespace OpenSim.Region.Framework.Scenes
960 985
961 if (grant.Length > 0) 986 if (grant.Length > 0)
962 { 987 {
963 foreach (string viewer in grant.Split('|')) 988 foreach (string viewer in grant.Split(','))
964 { 989 {
965 m_BannedViewers.Add(viewer.Trim().ToLower()); 990 m_BannedViewers.Add(viewer.Trim().ToLower());
966 } 991 }
@@ -1020,6 +1045,8 @@ namespace OpenSim.Region.Framework.Scenes
1020 StatsReporter = new SimStatsReporter(this); 1045 StatsReporter = new SimStatsReporter(this);
1021 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 1046 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
1022 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 1047 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
1048
1049 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
1023 } 1050 }
1024 1051
1025 public Scene(RegionInfo regInfo) : base(regInfo) 1052 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1315,8 +1342,11 @@ namespace OpenSim.Region.Framework.Scenes
1315 // Stop all client threads. 1342 // Stop all client threads.
1316 ForEachScenePresence(delegate(ScenePresence avatar) { CloseAgent(avatar.UUID, false); }); 1343 ForEachScenePresence(delegate(ScenePresence avatar) { CloseAgent(avatar.UUID, false); });
1317 1344
1318 m_log.Debug("[SCENE]: Persisting changed objects"); 1345 m_log.Debug("[SCENE]: TriggerSceneShuttingDown");
1319 EventManager.TriggerSceneShuttingDown(this); 1346 EventManager.TriggerSceneShuttingDown(this);
1347
1348 m_log.Debug("[SCENE]: Persisting changed objects");
1349
1320 Backup(false); 1350 Backup(false);
1321 m_sceneGraph.Close(); 1351 m_sceneGraph.Close();
1322 1352
@@ -1330,6 +1360,7 @@ namespace OpenSim.Region.Framework.Scenes
1330 // attempt to reference a null or disposed physics scene. 1360 // attempt to reference a null or disposed physics scene.
1331 if (PhysicsScene != null) 1361 if (PhysicsScene != null)
1332 { 1362 {
1363 m_log.Debug("[SCENE]: Dispose Physics");
1333 PhysicsScene phys = PhysicsScene; 1364 PhysicsScene phys = PhysicsScene;
1334 // remove the physics engine from both Scene and SceneGraph 1365 // remove the physics engine from both Scene and SceneGraph
1335 PhysicsScene = null; 1366 PhysicsScene = null;
@@ -1360,11 +1391,29 @@ namespace OpenSim.Region.Framework.Scenes
1360 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1391 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1361 if (m_heartbeatThread != null) 1392 if (m_heartbeatThread != null)
1362 { 1393 {
1394 m_hbRestarts++;
1395 if(m_hbRestarts > 10)
1396 Environment.Exit(1);
1397 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1398
1399//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1400//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1401//proc.EnableRaisingEvents=false;
1402//proc.StartInfo.FileName = "/bin/kill";
1403//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1404//proc.Start();
1405//proc.WaitForExit();
1406//Thread.Sleep(1000);
1407//Environment.Exit(1);
1363 m_heartbeatThread.Abort(); 1408 m_heartbeatThread.Abort();
1409 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1364 m_heartbeatThread = null; 1410 m_heartbeatThread = null;
1365 } 1411 }
1366// m_lastUpdate = Util.EnvironmentTickCount(); 1412// m_lastUpdate = Util.EnvironmentTickCount();
1367 1413
1414// m_sceneGraph.PreparePhysicsSimulation();
1415
1416
1368 m_heartbeatThread 1417 m_heartbeatThread
1369 = Watchdog.StartThread( 1418 = Watchdog.StartThread(
1370 Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); 1419 Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false);
@@ -1509,16 +1558,20 @@ namespace OpenSim.Region.Framework.Scenes
1509 endFrame = Frame + frames; 1558 endFrame = Frame + frames;
1510 1559
1511 float physicsFPS = 0f; 1560 float physicsFPS = 0f;
1512 int previousFrameTick, tmpMS; 1561 int tmpMS;
1513 int maintc = Util.EnvironmentTickCount(); 1562 int previousFrameTick;
1563 int maintc;
1564 int sleepMS;
1565 int framestart;
1514 1566
1515 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1567 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1516 { 1568 {
1569 framestart = Util.EnvironmentTickCount();
1517 ++Frame; 1570 ++Frame;
1518 1571
1519// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1572// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1520 1573
1521 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1574 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1522 1575
1523 try 1576 try
1524 { 1577 {
@@ -1572,6 +1625,7 @@ namespace OpenSim.Region.Framework.Scenes
1572 m_sceneGraph.UpdatePresences(); 1625 m_sceneGraph.UpdatePresences();
1573 1626
1574 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1627 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1628
1575 1629
1576 // Delete temp-on-rez stuff 1630 // Delete temp-on-rez stuff
1577 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1631 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1653,34 +1707,37 @@ namespace OpenSim.Region.Framework.Scenes
1653 1707
1654 Watchdog.UpdateThread(); 1708 Watchdog.UpdateThread();
1655 1709
1710 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1711
1712 StatsReporter.AddPhysicsFPS(physicsFPS);
1713 StatsReporter.AddTimeDilation(TimeDilation);
1714 StatsReporter.AddFPS(1);
1715
1716 StatsReporter.addAgentMS(agentMS);
1717 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1718 StatsReporter.addOtherMS(otherMS);
1719 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1720
1656 previousFrameTick = m_lastFrameTick; 1721 previousFrameTick = m_lastFrameTick;
1657 m_lastFrameTick = Util.EnvironmentTickCount(); 1722 m_lastFrameTick = Util.EnvironmentTickCount();
1658 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1723 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1659 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1724 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1660 1725
1726 m_firstHeartbeat = false;
1727
1728 sleepMS = Util.EnvironmentTickCount();
1729
1661 if (tmpMS > 0) 1730 if (tmpMS > 0)
1662 {
1663 Thread.Sleep(tmpMS); 1731 Thread.Sleep(tmpMS);
1664 spareMS += tmpMS;
1665 }
1666 1732
1667 frameMS = Util.EnvironmentTickCountSubtract(maintc); 1733 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1668 maintc = Util.EnvironmentTickCount(); 1734 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1669 1735 StatsReporter.addSleepMS(sleepMS);
1670 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1736 StatsReporter.addFrameMS(frameMS);
1671 1737
1672 // if (Frame%m_update_avatars == 0) 1738 // if (Frame%m_update_avatars == 0)
1673 // UpdateInWorldTime(); 1739 // UpdateInWorldTime();
1674 StatsReporter.AddPhysicsFPS(physicsFPS);
1675 StatsReporter.AddTimeDilation(TimeDilation);
1676 StatsReporter.AddFPS(1);
1677 1740
1678 StatsReporter.addFrameMS(frameMS);
1679 StatsReporter.addAgentMS(agentMS);
1680 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1681 StatsReporter.addOtherMS(otherMS);
1682 StatsReporter.AddSpareMS(spareMS);
1683 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1684 1741
1685 // Optionally warn if a frame takes double the amount of time that it should. 1742 // Optionally warn if a frame takes double the amount of time that it should.
1686 if (DebugUpdates 1743 if (DebugUpdates
@@ -1697,7 +1754,7 @@ namespace OpenSim.Region.Framework.Scenes
1697 public void AddGroupTarget(SceneObjectGroup grp) 1754 public void AddGroupTarget(SceneObjectGroup grp)
1698 { 1755 {
1699 lock (m_groupsWithTargets) 1756 lock (m_groupsWithTargets)
1700 m_groupsWithTargets[grp.UUID] = grp; 1757 m_groupsWithTargets[grp.UUID] = 0;
1701 } 1758 }
1702 1759
1703 public void RemoveGroupTarget(SceneObjectGroup grp) 1760 public void RemoveGroupTarget(SceneObjectGroup grp)
@@ -1708,18 +1765,24 @@ namespace OpenSim.Region.Framework.Scenes
1708 1765
1709 private void CheckAtTargets() 1766 private void CheckAtTargets()
1710 { 1767 {
1711 List<SceneObjectGroup> objs = null; 1768 List<UUID> objs = null;
1712 1769
1713 lock (m_groupsWithTargets) 1770 lock (m_groupsWithTargets)
1714 { 1771 {
1715 if (m_groupsWithTargets.Count != 0) 1772 if (m_groupsWithTargets.Count != 0)
1716 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); 1773 objs = new List<UUID>(m_groupsWithTargets.Keys);
1717 } 1774 }
1718 1775
1719 if (objs != null) 1776 if (objs != null)
1720 { 1777 {
1721 foreach (SceneObjectGroup entry in objs) 1778 foreach (UUID entry in objs)
1722 entry.checkAtTargets(); 1779 {
1780 SceneObjectGroup grp = GetSceneObjectGroup(entry);
1781 if (grp == null)
1782 m_groupsWithTargets.Remove(entry);
1783 else
1784 grp.checkAtTargets();
1785 }
1723 } 1786 }
1724 } 1787 }
1725 1788
@@ -1798,7 +1861,7 @@ namespace OpenSim.Region.Framework.Scenes
1798 msg.fromAgentName = "Server"; 1861 msg.fromAgentName = "Server";
1799 msg.dialog = (byte)19; // Object msg 1862 msg.dialog = (byte)19; // Object msg
1800 msg.fromGroup = false; 1863 msg.fromGroup = false;
1801 msg.offline = (byte)0; 1864 msg.offline = (byte)1;
1802 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1865 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1803 msg.Position = Vector3.Zero; 1866 msg.Position = Vector3.Zero;
1804 msg.RegionID = RegionInfo.RegionID.Guid; 1867 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -2032,7 +2095,7 @@ namespace OpenSim.Region.Framework.Scenes
2032 return PhysicsScene.SupportsRaycastWorldFiltered(); 2095 return PhysicsScene.SupportsRaycastWorldFiltered();
2033 } 2096 }
2034 2097
2035 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) 2098 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2036 { 2099 {
2037 if (PhysicsScene == null) 2100 if (PhysicsScene == null)
2038 return null; 2101 return null;
@@ -2054,14 +2117,24 @@ namespace OpenSim.Region.Framework.Scenes
2054 /// <returns></returns> 2117 /// <returns></returns>
2055 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2118 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
2056 { 2119 {
2120
2121 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2122 Vector3 wpos = Vector3.Zero;
2123 // Check for water surface intersection from above
2124 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2125 {
2126 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2127 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2128 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2129 wpos.Z = wheight;
2130 }
2131
2057 Vector3 pos = Vector3.Zero; 2132 Vector3 pos = Vector3.Zero;
2058 if (RayEndIsIntersection == (byte)1) 2133 if (RayEndIsIntersection == (byte)1)
2059 { 2134 {
2060 pos = RayEnd; 2135 pos = RayEnd;
2061 return pos;
2062 } 2136 }
2063 2137 else if (RayTargetID != UUID.Zero)
2064 if (RayTargetID != UUID.Zero)
2065 { 2138 {
2066 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2139 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
2067 2140
@@ -2083,7 +2156,7 @@ namespace OpenSim.Region.Framework.Scenes
2083 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2156 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2084 2157
2085 // Un-comment out the following line to Get Raytrace results printed to the console. 2158 // Un-comment out the following line to Get Raytrace results printed to the console.
2086 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2159 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2087 float ScaleOffset = 0.5f; 2160 float ScaleOffset = 0.5f;
2088 2161
2089 // If we hit something 2162 // If we hit something
@@ -2106,13 +2179,10 @@ namespace OpenSim.Region.Framework.Scenes
2106 //pos.Z -= 0.25F; 2179 //pos.Z -= 0.25F;
2107 2180
2108 } 2181 }
2109
2110 return pos;
2111 } 2182 }
2112 else 2183 else
2113 { 2184 {
2114 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2185 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2115
2116 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2186 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2117 2187
2118 // Un-comment the following line to print the raytrace results to the console. 2188 // Un-comment the following line to print the raytrace results to the console.
@@ -2121,13 +2191,12 @@ namespace OpenSim.Region.Framework.Scenes
2121 if (ei.HitTF) 2191 if (ei.HitTF)
2122 { 2192 {
2123 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2193 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2124 } else 2194 }
2195 else
2125 { 2196 {
2126 // fall back to our stupid functionality 2197 // fall back to our stupid functionality
2127 pos = RayEnd; 2198 pos = RayEnd;
2128 } 2199 }
2129
2130 return pos;
2131 } 2200 }
2132 } 2201 }
2133 else 2202 else
@@ -2138,8 +2207,12 @@ namespace OpenSim.Region.Framework.Scenes
2138 //increase height so its above the ground. 2207 //increase height so its above the ground.
2139 //should be getting the normal of the ground at the rez point and using that? 2208 //should be getting the normal of the ground at the rez point and using that?
2140 pos.Z += scale.Z / 2f; 2209 pos.Z += scale.Z / 2f;
2141 return pos; 2210// return pos;
2142 } 2211 }
2212
2213 // check against posible water intercept
2214 if (wpos.Z > pos.Z) pos = wpos;
2215 return pos;
2143 } 2216 }
2144 2217
2145 2218
@@ -2230,12 +2303,12 @@ namespace OpenSim.Region.Framework.Scenes
2230 { 2303 {
2231 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) 2304 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2232 { 2305 {
2306 sceneObject.IsDeleted = false;
2233 EventManager.TriggerObjectAddedToScene(sceneObject); 2307 EventManager.TriggerObjectAddedToScene(sceneObject);
2234 return true; 2308 return true;
2235 } 2309 }
2236 2310
2237 return false; 2311 return false;
2238
2239 } 2312 }
2240 2313
2241 /// <summary> 2314 /// <summary>
@@ -2327,6 +2400,15 @@ namespace OpenSim.Region.Framework.Scenes
2327 /// </summary> 2400 /// </summary>
2328 public void DeleteAllSceneObjects() 2401 public void DeleteAllSceneObjects()
2329 { 2402 {
2403 DeleteAllSceneObjects(false);
2404 }
2405
2406 /// <summary>
2407 /// Delete every object from the scene. This does not include attachments worn by avatars.
2408 /// </summary>
2409 public void DeleteAllSceneObjects(bool exceptNoCopy)
2410 {
2411 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2330 lock (Entities) 2412 lock (Entities)
2331 { 2413 {
2332 EntityBase[] entities = Entities.GetEntities(); 2414 EntityBase[] entities = Entities.GetEntities();
@@ -2335,11 +2417,24 @@ namespace OpenSim.Region.Framework.Scenes
2335 if (e is SceneObjectGroup) 2417 if (e is SceneObjectGroup)
2336 { 2418 {
2337 SceneObjectGroup sog = (SceneObjectGroup)e; 2419 SceneObjectGroup sog = (SceneObjectGroup)e;
2338 if (!sog.IsAttachment) 2420 if (sog != null && !sog.IsAttachment)
2339 DeleteSceneObject((SceneObjectGroup)e, false); 2421 {
2422 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2423 {
2424 DeleteSceneObject((SceneObjectGroup)e, false);
2425 }
2426 else
2427 {
2428 toReturn.Add((SceneObjectGroup)e);
2429 }
2430 }
2340 } 2431 }
2341 } 2432 }
2342 } 2433 }
2434 if (toReturn.Count > 0)
2435 {
2436 returnObjects(toReturn.ToArray(), UUID.Zero);
2437 }
2343 } 2438 }
2344 2439
2345 /// <summary> 2440 /// <summary>
@@ -2370,6 +2465,14 @@ namespace OpenSim.Region.Framework.Scenes
2370 else 2465 else
2371 group.StopScriptInstances(); 2466 group.StopScriptInstances();
2372 2467
2468 List<UUID> avatars = group.GetSittingAvatars();
2469 foreach (UUID av in avatars)
2470 {
2471 ScenePresence p = GetScenePresence(av);
2472 if (p != null)
2473 p.StandUp();
2474 }
2475
2373 SceneObjectPart[] partList = group.Parts; 2476 SceneObjectPart[] partList = group.Parts;
2374 2477
2375 foreach (SceneObjectPart part in partList) 2478 foreach (SceneObjectPart part in partList)
@@ -2397,6 +2500,8 @@ namespace OpenSim.Region.Framework.Scenes
2397 } 2500 }
2398 2501
2399 group.DeleteGroupFromScene(silent); 2502 group.DeleteGroupFromScene(silent);
2503 if (!silent)
2504 SendKillObject(new List<uint>() { group.LocalId });
2400 2505
2401// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2506// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2402 } 2507 }
@@ -2686,7 +2791,7 @@ namespace OpenSim.Region.Framework.Scenes
2686 // If the user is banned, we won't let any of their objects 2791 // If the user is banned, we won't let any of their objects
2687 // enter. Period. 2792 // enter. Period.
2688 // 2793 //
2689 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2794 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2690 { 2795 {
2691 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2796 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2692 return false; 2797 return false;
@@ -2722,8 +2827,10 @@ namespace OpenSim.Region.Framework.Scenes
2722 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2827 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2723 newObject.ResumeScripts(); 2828 newObject.ResumeScripts();
2724 2829
2725 if (newObject.RootPart.KeyframeMotion != null) 2830 // AddSceneObject already does this and doing it again messes
2726 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); 2831 // up region crossings, so don't.
2832 //if (newObject.RootPart.KeyframeMotion != null)
2833 // newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2727 } 2834 }
2728 2835
2729 // Do this as late as possible so that listeners have full access to the incoming object 2836 // Do this as late as possible so that listeners have full access to the incoming object
@@ -2741,6 +2848,23 @@ namespace OpenSim.Region.Framework.Scenes
2741 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2848 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2742 public bool AddSceneObject(SceneObjectGroup sceneObject) 2849 public bool AddSceneObject(SceneObjectGroup sceneObject)
2743 { 2850 {
2851 if (sceneObject.OwnerID == UUID.Zero)
2852 {
2853 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2854 return false;
2855 }
2856
2857 // If the user is banned, we won't let any of their objects
2858 // enter. Period.
2859 //
2860 int flags = GetUserFlags(sceneObject.OwnerID);
2861 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2862 {
2863 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2864
2865 return false;
2866 }
2867
2744 // Force allocation of new LocalId 2868 // Force allocation of new LocalId
2745 // 2869 //
2746 SceneObjectPart[] parts = sceneObject.Parts; 2870 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2777,16 +2901,27 @@ namespace OpenSim.Region.Framework.Scenes
2777 // information that this is due to a teleport/border cross rather than an ordinary attachment. 2901 // information that this is due to a teleport/border cross rather than an ordinary attachment.
2778 // We currently do this in Scene.MakeRootAgent() instead. 2902 // We currently do this in Scene.MakeRootAgent() instead.
2779 if (AttachmentsModule != null) 2903 if (AttachmentsModule != null)
2780 AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); 2904 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true);
2781 } 2905 }
2782 else 2906 else
2783 { 2907 {
2908 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2784 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2909 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2785 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2910 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2786 } 2911 }
2912 if (sceneObject.OwnerID == UUID.Zero)
2913 {
2914 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2915 return false;
2916 }
2787 } 2917 }
2788 else 2918 else
2789 { 2919 {
2920 if (sceneObject.OwnerID == UUID.Zero)
2921 {
2922 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2923 return false;
2924 }
2790 AddRestoredSceneObject(sceneObject, true, false); 2925 AddRestoredSceneObject(sceneObject, true, false);
2791 } 2926 }
2792 2927
@@ -2803,6 +2938,24 @@ namespace OpenSim.Region.Framework.Scenes
2803 return 2; // StateSource.PrimCrossing 2938 return 2; // StateSource.PrimCrossing
2804 } 2939 }
2805 2940
2941 public int GetUserFlags(UUID user)
2942 {
2943 //Unfortunately the SP approach means that the value is cached until region is restarted
2944 /*
2945 ScenePresence sp;
2946 if (TryGetScenePresence(user, out sp))
2947 {
2948 return sp.UserFlags;
2949 }
2950 else
2951 {
2952 */
2953 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2954 if (uac == null)
2955 return 0;
2956 return uac.UserFlags;
2957 //}
2958 }
2806 #endregion 2959 #endregion
2807 2960
2808 #region Add/Remove Avatar Methods 2961 #region Add/Remove Avatar Methods
@@ -2836,7 +2989,7 @@ namespace OpenSim.Region.Framework.Scenes
2836 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2989 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2837 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2990 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2838 2991
2839 // CheckHeartbeat(); 2992 CheckHeartbeat();
2840 2993
2841 sp = GetScenePresence(client.AgentId); 2994 sp = GetScenePresence(client.AgentId);
2842 2995
@@ -2854,6 +3007,13 @@ namespace OpenSim.Region.Framework.Scenes
2854 SubscribeToClientEvents(client); 3007 SubscribeToClientEvents(client);
2855 3008
2856 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 3009 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
3010 InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
3011 if (cof == null)
3012 sp.COF = UUID.Zero;
3013 else
3014 sp.COF = cof.ID;
3015
3016 m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
2857 m_eventManager.TriggerOnNewPresence(sp); 3017 m_eventManager.TriggerOnNewPresence(sp);
2858 3018
2859 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 3019 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
@@ -2974,19 +3134,15 @@ namespace OpenSim.Region.Framework.Scenes
2974 // and the scene presence and the client, if they exist 3134 // and the scene presence and the client, if they exist
2975 try 3135 try
2976 { 3136 {
2977 // We need to wait for the client to make UDP contact first. 3137 ScenePresence sp = GetScenePresence(agentID);
2978 // It's the UDP contact that creates the scene presence 3138
2979 ScenePresence sp = WaitGetScenePresence(agentID);
2980 if (sp != null) 3139 if (sp != null)
2981 { 3140 {
2982 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3141 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2983 3142
2984 CloseAgent(sp.UUID, false); 3143 CloseAgent(sp.UUID, false);
2985 } 3144 }
2986 else 3145
2987 {
2988 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2989 }
2990 // BANG! SLASH! 3146 // BANG! SLASH!
2991 m_authenticateHandler.RemoveCircuit(agentID); 3147 m_authenticateHandler.RemoveCircuit(agentID);
2992 3148
@@ -3031,6 +3187,8 @@ namespace OpenSim.Region.Framework.Scenes
3031 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3187 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
3032 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3188 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
3033 3189
3190 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3191
3034 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3192 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
3035 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3193 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
3036 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3194 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -3087,6 +3245,7 @@ namespace OpenSim.Region.Framework.Scenes
3087 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3245 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
3088 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3246 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
3089 client.OnCopyInventoryItem += CopyInventoryItem; 3247 client.OnCopyInventoryItem += CopyInventoryItem;
3248 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
3090 client.OnMoveInventoryItem += MoveInventoryItem; 3249 client.OnMoveInventoryItem += MoveInventoryItem;
3091 client.OnRemoveInventoryItem += RemoveInventoryItem; 3250 client.OnRemoveInventoryItem += RemoveInventoryItem;
3092 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3251 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3156,6 +3315,8 @@ namespace OpenSim.Region.Framework.Scenes
3156 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3315 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3157 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3316 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3158 3317
3318 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3319
3159 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3320 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3160 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3321 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3161 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3322 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3467,7 +3628,7 @@ namespace OpenSim.Region.Framework.Scenes
3467 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3628 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3468 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3629 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3469 if (closeChildAgents && CapsModule != null) 3630 if (closeChildAgents && CapsModule != null)
3470 CapsModule.RemoveCaps(agentID); 3631 CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode);
3471 3632
3472 if (closeChildAgents && !isChildAgent) 3633 if (closeChildAgents && !isChildAgent)
3473 { 3634 {
@@ -3500,6 +3661,7 @@ namespace OpenSim.Region.Framework.Scenes
3500 // It's possible for child agents to have transactions if changes are being made cross-border. 3661 // It's possible for child agents to have transactions if changes are being made cross-border.
3501 if (AgentTransactionsModule != null) 3662 if (AgentTransactionsModule != null)
3502 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3663 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3664 m_log.Debug("[Scene] The avatar has left the building");
3503 } 3665 }
3504 catch (Exception e) 3666 catch (Exception e)
3505 { 3667 {
@@ -3807,13 +3969,16 @@ namespace OpenSim.Region.Framework.Scenes
3807 // On login test land permisions 3969 // On login test land permisions
3808 if (vialogin) 3970 if (vialogin)
3809 { 3971 {
3972 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3973 if (cache != null)
3974 cache.Remove(acd.firstname + " " + acd.lastname);
3810 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) 3975 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y))
3811 { 3976 {
3812 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 3977 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3813 return false; 3978 return false;
3814 } 3979 }
3815 } 3980 }
3816 3981
3817 if (sp == null) // We don't have an [child] agent here already 3982 if (sp == null) // We don't have an [child] agent here already
3818 { 3983 {
3819 if (requirePresenceLookup) 3984 if (requirePresenceLookup)
@@ -3835,7 +4000,7 @@ namespace OpenSim.Region.Framework.Scenes
3835 return false; 4000 return false;
3836 } 4001 }
3837 } 4002 }
3838 4003
3839 try 4004 try
3840 { 4005 {
3841 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) 4006 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason))
@@ -3852,7 +4017,7 @@ namespace OpenSim.Region.Framework.Scenes
3852 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 4017 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3853 return false; 4018 return false;
3854 } 4019 }
3855 4020
3856 m_log.InfoFormat( 4021 m_log.InfoFormat(
3857 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 4022 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3858 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, 4023 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname,
@@ -3861,7 +4026,7 @@ namespace OpenSim.Region.Framework.Scenes
3861 if (CapsModule != null) 4026 if (CapsModule != null)
3862 { 4027 {
3863 CapsModule.SetAgentCapsSeeds(acd); 4028 CapsModule.SetAgentCapsSeeds(acd);
3864 CapsModule.CreateCaps(acd.AgentID); 4029 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3865 } 4030 }
3866 } 4031 }
3867 else 4032 else
@@ -3881,7 +4046,7 @@ namespace OpenSim.Region.Framework.Scenes
3881 if (CapsModule != null) 4046 if (CapsModule != null)
3882 { 4047 {
3883 CapsModule.SetAgentCapsSeeds(acd); 4048 CapsModule.SetAgentCapsSeeds(acd);
3884 CapsModule.CreateCaps(acd.AgentID); 4049 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3885 } 4050 }
3886 } 4051 }
3887 } 4052 }
@@ -3892,6 +4057,11 @@ namespace OpenSim.Region.Framework.Scenes
3892 CacheUserName(null, acd); 4057 CacheUserName(null, acd);
3893 } 4058 }
3894 4059
4060 if (CapsModule != null)
4061 {
4062 CapsModule.ActivateCaps(acd.circuitcode);
4063 }
4064
3895 if (vialogin) 4065 if (vialogin)
3896 { 4066 {
3897// CleanDroppedAttachments(); 4067// CleanDroppedAttachments();
@@ -4003,6 +4173,8 @@ namespace OpenSim.Region.Framework.Scenes
4003 } 4173 }
4004 4174
4005 // Honor parcel landing type and position. 4175 // Honor parcel landing type and position.
4176 /*
4177 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
4006 if (land != null) 4178 if (land != null)
4007 { 4179 {
4008 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 4180 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -4010,6 +4182,7 @@ namespace OpenSim.Region.Framework.Scenes
4010 acd.startpos = land.LandData.UserLocation; 4182 acd.startpos = land.LandData.UserLocation;
4011 } 4183 }
4012 } 4184 }
4185 */// This is now handled properly in ScenePresence.MakeRootAgent
4013 } 4186 }
4014 4187
4015 return true; 4188 return true;
@@ -4107,7 +4280,7 @@ namespace OpenSim.Region.Framework.Scenes
4107 4280
4108 if (!m_strictAccessControl) return true; 4281 if (!m_strictAccessControl) return true;
4109 if (Permissions.IsGod(agent.AgentID)) return true; 4282 if (Permissions.IsGod(agent.AgentID)) return true;
4110 4283
4111 if (AuthorizationService != null) 4284 if (AuthorizationService != null)
4112 { 4285 {
4113 if (!AuthorizationService.IsAuthorizedForRegion( 4286 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -4128,7 +4301,8 @@ namespace OpenSim.Region.Framework.Scenes
4128 { 4301 {
4129 if (RegionInfo.EstateSettings != null) 4302 if (RegionInfo.EstateSettings != null)
4130 { 4303 {
4131 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4304 int flags = GetUserFlags(agent.AgentID);
4305 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, flags))
4132 { 4306 {
4133 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4307 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
4134 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4308 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4317,6 +4491,15 @@ namespace OpenSim.Region.Framework.Scenes
4317 m_log.DebugFormat( 4491 m_log.DebugFormat(
4318 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 4492 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
4319 4493
4494 // We have to wait until the viewer contacts this region after receiving EAC.
4495 // That calls AddNewClient, which finally creates the ScenePresence
4496 int flags = GetUserFlags(cAgentData.AgentID);
4497 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4498 {
4499 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4500 return false;
4501 }
4502
4320 // TODO: This check should probably be in QueryAccess(). 4503 // TODO: This check should probably be in QueryAccess().
4321 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4504 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4322 if (nearestParcel == null) 4505 if (nearestParcel == null)
@@ -4417,7 +4600,7 @@ namespace OpenSim.Region.Framework.Scenes
4417 /// <param name='agentID'></param> 4600 /// <param name='agentID'></param>
4418 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4601 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4419 { 4602 {
4420 int ntimes = 20; 4603 int ntimes = 30;
4421 ScenePresence sp = null; 4604 ScenePresence sp = null;
4422 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4605 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4423 Thread.Sleep(1000); 4606 Thread.Sleep(1000);
@@ -4467,6 +4650,16 @@ namespace OpenSim.Region.Framework.Scenes
4467 return false; 4650 return false;
4468 } 4651 }
4469 4652
4653// public bool IncomingCloseAgent(UUID agentID)
4654// {
4655// return IncomingCloseAgent(agentID, false);
4656// }
4657
4658// public bool IncomingCloseChildAgent(UUID agentID)
4659// {
4660// return IncomingCloseAgent(agentID, true);
4661// }
4662
4470 /// <summary> 4663 /// <summary>
4471 /// Tell a single client to prepare to close. 4664 /// Tell a single client to prepare to close.
4472 /// </summary> 4665 /// </summary>
@@ -4565,7 +4758,7 @@ namespace OpenSim.Region.Framework.Scenes
4565 4758
4566 if (sp != null) 4759 if (sp != null)
4567 { 4760 {
4568 sp.ControllingClient.Close(force); 4761 sp.ControllingClient.Close(force, force);
4569 return true; 4762 return true;
4570 } 4763 }
4571 4764
@@ -5183,7 +5376,7 @@ namespace OpenSim.Region.Framework.Scenes
5183 { 5376 {
5184 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 5377 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
5185 { 5378 {
5186 if (grp.RootPart.Expires <= DateTime.Now) 5379 if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now)
5187 DeleteSceneObject(grp, false); 5380 DeleteSceneObject(grp, false);
5188 } 5381 }
5189 } 5382 }
@@ -5197,35 +5390,81 @@ namespace OpenSim.Region.Framework.Scenes
5197 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5390 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
5198 } 5391 }
5199 5392
5200 public int GetHealth() 5393 public int GetHealth(out int flags, out string message)
5201 { 5394 {
5202 // Returns: 5395 // Returns:
5203 // 1 = sim is up and accepting http requests. The heartbeat has 5396 // 1 = sim is up and accepting http requests. The heartbeat has
5204 // stopped and the sim is probably locked up, but a remote 5397 // stopped and the sim is probably locked up, but a remote
5205 // admin restart may succeed 5398 // admin restart may succeed
5206 // 5399 //
5207 // 2 = Sim is up and the heartbeat is running. The sim is likely 5400 // 2 = Sim is up and the heartbeat is running. The sim is likely
5208 // usable for people within and logins _may_ work 5401 // usable for people within
5402 //
5403 // 3 = Sim is up and one packet thread is running. Sim is
5404 // unstable and will not accept new logins
5209 // 5405 //
5210 // 3 = We have seen a new user enter within the past 4 minutes 5406 // 4 = Sim is up and both packet threads are running. Sim is
5407 // likely usable
5408 //
5409 // 5 = We have seen a new user enter within the past 4 minutes
5211 // which can be seen as positive confirmation of sim health 5410 // which can be seen as positive confirmation of sim health
5212 // 5411 //
5412
5413 flags = 0;
5414 message = String.Empty;
5415
5416 CheckHeartbeat();
5417
5418 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5419 {
5420 // We're still starting
5421 // 0 means "in startup", it can't happen another way, since
5422 // to get here, we must be able to accept http connections
5423 return 0;
5424 }
5425
5213 int health=1; // Start at 1, means we're up 5426 int health=1; // Start at 1, means we're up
5214 5427
5215 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5428 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
5216 health += 1; 5429 {
5430 health+=1;
5431 flags |= 1;
5432 }
5433
5434 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5435 {
5436 health+=1;
5437 flags |= 2;
5438 }
5439
5440 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5441 {
5442 health+=1;
5443 flags |= 4;
5444 }
5217 else 5445 else
5446 {
5447int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5448System.Diagnostics.Process proc = new System.Diagnostics.Process();
5449proc.EnableRaisingEvents=false;
5450proc.StartInfo.FileName = "/bin/kill";
5451proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5452proc.Start();
5453proc.WaitForExit();
5454Thread.Sleep(1000);
5455Environment.Exit(1);
5456 }
5457
5458 if (flags != 7)
5218 return health; 5459 return health;
5219 5460
5220 // A login in the last 4 mins? We can't be doing too badly 5461 // A login in the last 4 mins? We can't be doing too badly
5221 // 5462 //
5222 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5463 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
5223 health++; 5464 health++;
5224 else 5465 else
5225 return health; 5466 return health;
5226 5467
5227// CheckHeartbeat();
5228
5229 return health; 5468 return health;
5230 } 5469 }
5231 5470
@@ -5313,7 +5552,7 @@ namespace OpenSim.Region.Framework.Scenes
5313 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5552 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5314 if (wasUsingPhysics) 5553 if (wasUsingPhysics)
5315 { 5554 {
5316 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 5555 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
5317 } 5556 }
5318 } 5557 }
5319 5558
@@ -5412,14 +5651,14 @@ namespace OpenSim.Region.Framework.Scenes
5412 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5651 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5413 } 5652 }
5414 5653
5415// private void CheckHeartbeat() 5654 private void CheckHeartbeat()
5416// { 5655 {
5417// if (m_firstHeartbeat) 5656 if (m_firstHeartbeat)
5418// return; 5657 return;
5419// 5658
5420// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5659 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5421// StartTimer(); 5660 Start();
5422// } 5661 }
5423 5662
5424 public override ISceneObject DeserializeObject(string representation) 5663 public override ISceneObject DeserializeObject(string representation)
5425 { 5664 {
@@ -5477,7 +5716,7 @@ namespace OpenSim.Region.Framework.Scenes
5477 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); 5716 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
5478 5717
5479 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); 5718 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
5480 5719
5481 return nearestRegionEdgePoint; 5720 return nearestRegionEdgePoint;
5482 } 5721 }
5483 5722
@@ -5731,7 +5970,55 @@ namespace OpenSim.Region.Framework.Scenes
5731 mapModule.GenerateMaptile(); 5970 mapModule.GenerateMaptile();
5732 } 5971 }
5733 5972
5734 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5973// public void CleanDroppedAttachments()
5974// {
5975// List<SceneObjectGroup> objectsToDelete =
5976// new List<SceneObjectGroup>();
5977//
5978// lock (m_cleaningAttachments)
5979// {
5980// ForEachSOG(delegate (SceneObjectGroup grp)
5981// {
5982// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5983// {
5984// UUID agentID = grp.OwnerID;
5985// if (agentID == UUID.Zero)
5986// {
5987// objectsToDelete.Add(grp);
5988// return;
5989// }
5990//
5991// ScenePresence sp = GetScenePresence(agentID);
5992// if (sp == null)
5993// {
5994// objectsToDelete.Add(grp);
5995// return;
5996// }
5997// }
5998// });
5999// }
6000//
6001// foreach (SceneObjectGroup grp in objectsToDelete)
6002// {
6003// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
6004// DeleteSceneObject(grp, true);
6005// }
6006// }
6007
6008 public void ThreadAlive(int threadCode)
6009 {
6010 switch(threadCode)
6011 {
6012 case 1: // Incoming
6013 m_lastIncoming = Util.EnvironmentTickCount();
6014 break;
6015 case 2: // Incoming
6016 m_lastOutgoing = Util.EnvironmentTickCount();
6017 break;
6018 }
6019 }
6020
6021 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5735 { 6022 {
5736 RegenerateMaptile(); 6023 RegenerateMaptile();
5737 6024
@@ -5882,7 +6169,19 @@ namespace OpenSim.Region.Framework.Scenes
5882 return true; 6169 return true;
5883 } 6170 }
5884 6171
5885 /// <summary> 6172 public void StartTimerWatchdog()
6173 {
6174 m_timerWatchdog.Interval = 1000;
6175 m_timerWatchdog.Elapsed += TimerWatchdog;
6176 m_timerWatchdog.AutoReset = true;
6177 m_timerWatchdog.Start();
6178 }
6179
6180 public void TimerWatchdog(object sender, ElapsedEventArgs e)
6181 {
6182 CheckHeartbeat();
6183 }
6184
5886 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 6185 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5887 /// autopilot that moves an avatar to a sit target!. 6186 /// autopilot that moves an avatar to a sit target!.
5888 /// </summary> 6187 /// </summary>
@@ -5961,6 +6260,11 @@ namespace OpenSim.Region.Framework.Scenes
5961 return m_SpawnPoint - 1; 6260 return m_SpawnPoint - 1;
5962 } 6261 }
5963 6262
6263 private void HandleGcCollect(string module, string[] args)
6264 {
6265 GC.Collect();
6266 }
6267
5964 /// <summary> 6268 /// <summary>
5965 /// Wrappers to get physics modules retrieve assets. 6269 /// Wrappers to get physics modules retrieve assets.
5966 /// </summary> 6270 /// </summary>