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 7772f94..21036d8 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;
@@ -2027,7 +2090,7 @@ namespace OpenSim.Region.Framework.Scenes
2027 return PhysicsScene.SupportsRaycastWorldFiltered(); 2090 return PhysicsScene.SupportsRaycastWorldFiltered();
2028 } 2091 }
2029 2092
2030 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) 2093 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2031 { 2094 {
2032 if (PhysicsScene == null) 2095 if (PhysicsScene == null)
2033 return null; 2096 return null;
@@ -2049,14 +2112,24 @@ namespace OpenSim.Region.Framework.Scenes
2049 /// <returns></returns> 2112 /// <returns></returns>
2050 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2113 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
2051 { 2114 {
2115
2116 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2117 Vector3 wpos = Vector3.Zero;
2118 // Check for water surface intersection from above
2119 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2120 {
2121 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2122 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2123 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2124 wpos.Z = wheight;
2125 }
2126
2052 Vector3 pos = Vector3.Zero; 2127 Vector3 pos = Vector3.Zero;
2053 if (RayEndIsIntersection == (byte)1) 2128 if (RayEndIsIntersection == (byte)1)
2054 { 2129 {
2055 pos = RayEnd; 2130 pos = RayEnd;
2056 return pos;
2057 } 2131 }
2058 2132 else if (RayTargetID != UUID.Zero)
2059 if (RayTargetID != UUID.Zero)
2060 { 2133 {
2061 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2134 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
2062 2135
@@ -2078,7 +2151,7 @@ namespace OpenSim.Region.Framework.Scenes
2078 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2151 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2079 2152
2080 // Un-comment out the following line to Get Raytrace results printed to the console. 2153 // Un-comment out the following line to Get Raytrace results printed to the console.
2081 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2154 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2082 float ScaleOffset = 0.5f; 2155 float ScaleOffset = 0.5f;
2083 2156
2084 // If we hit something 2157 // If we hit something
@@ -2101,13 +2174,10 @@ namespace OpenSim.Region.Framework.Scenes
2101 //pos.Z -= 0.25F; 2174 //pos.Z -= 0.25F;
2102 2175
2103 } 2176 }
2104
2105 return pos;
2106 } 2177 }
2107 else 2178 else
2108 { 2179 {
2109 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2180 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2110
2111 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2181 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2112 2182
2113 // Un-comment the following line to print the raytrace results to the console. 2183 // Un-comment the following line to print the raytrace results to the console.
@@ -2116,13 +2186,12 @@ namespace OpenSim.Region.Framework.Scenes
2116 if (ei.HitTF) 2186 if (ei.HitTF)
2117 { 2187 {
2118 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2188 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2119 } else 2189 }
2190 else
2120 { 2191 {
2121 // fall back to our stupid functionality 2192 // fall back to our stupid functionality
2122 pos = RayEnd; 2193 pos = RayEnd;
2123 } 2194 }
2124
2125 return pos;
2126 } 2195 }
2127 } 2196 }
2128 else 2197 else
@@ -2133,8 +2202,12 @@ namespace OpenSim.Region.Framework.Scenes
2133 //increase height so its above the ground. 2202 //increase height so its above the ground.
2134 //should be getting the normal of the ground at the rez point and using that? 2203 //should be getting the normal of the ground at the rez point and using that?
2135 pos.Z += scale.Z / 2f; 2204 pos.Z += scale.Z / 2f;
2136 return pos; 2205// return pos;
2137 } 2206 }
2207
2208 // check against posible water intercept
2209 if (wpos.Z > pos.Z) pos = wpos;
2210 return pos;
2138 } 2211 }
2139 2212
2140 2213
@@ -2225,12 +2298,12 @@ namespace OpenSim.Region.Framework.Scenes
2225 { 2298 {
2226 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) 2299 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2227 { 2300 {
2301 sceneObject.IsDeleted = false;
2228 EventManager.TriggerObjectAddedToScene(sceneObject); 2302 EventManager.TriggerObjectAddedToScene(sceneObject);
2229 return true; 2303 return true;
2230 } 2304 }
2231 2305
2232 return false; 2306 return false;
2233
2234 } 2307 }
2235 2308
2236 /// <summary> 2309 /// <summary>
@@ -2322,6 +2395,15 @@ namespace OpenSim.Region.Framework.Scenes
2322 /// </summary> 2395 /// </summary>
2323 public void DeleteAllSceneObjects() 2396 public void DeleteAllSceneObjects()
2324 { 2397 {
2398 DeleteAllSceneObjects(false);
2399 }
2400
2401 /// <summary>
2402 /// Delete every object from the scene. This does not include attachments worn by avatars.
2403 /// </summary>
2404 public void DeleteAllSceneObjects(bool exceptNoCopy)
2405 {
2406 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2325 lock (Entities) 2407 lock (Entities)
2326 { 2408 {
2327 EntityBase[] entities = Entities.GetEntities(); 2409 EntityBase[] entities = Entities.GetEntities();
@@ -2330,11 +2412,24 @@ namespace OpenSim.Region.Framework.Scenes
2330 if (e is SceneObjectGroup) 2412 if (e is SceneObjectGroup)
2331 { 2413 {
2332 SceneObjectGroup sog = (SceneObjectGroup)e; 2414 SceneObjectGroup sog = (SceneObjectGroup)e;
2333 if (!sog.IsAttachment) 2415 if (sog != null && !sog.IsAttachment)
2334 DeleteSceneObject((SceneObjectGroup)e, false); 2416 {
2417 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2418 {
2419 DeleteSceneObject((SceneObjectGroup)e, false);
2420 }
2421 else
2422 {
2423 toReturn.Add((SceneObjectGroup)e);
2424 }
2425 }
2335 } 2426 }
2336 } 2427 }
2337 } 2428 }
2429 if (toReturn.Count > 0)
2430 {
2431 returnObjects(toReturn.ToArray(), UUID.Zero);
2432 }
2338 } 2433 }
2339 2434
2340 /// <summary> 2435 /// <summary>
@@ -2365,6 +2460,14 @@ namespace OpenSim.Region.Framework.Scenes
2365 else 2460 else
2366 group.StopScriptInstances(); 2461 group.StopScriptInstances();
2367 2462
2463 List<UUID> avatars = group.GetSittingAvatars();
2464 foreach (UUID av in avatars)
2465 {
2466 ScenePresence p = GetScenePresence(av);
2467 if (p != null)
2468 p.StandUp();
2469 }
2470
2368 SceneObjectPart[] partList = group.Parts; 2471 SceneObjectPart[] partList = group.Parts;
2369 2472
2370 foreach (SceneObjectPart part in partList) 2473 foreach (SceneObjectPart part in partList)
@@ -2392,6 +2495,8 @@ namespace OpenSim.Region.Framework.Scenes
2392 } 2495 }
2393 2496
2394 group.DeleteGroupFromScene(silent); 2497 group.DeleteGroupFromScene(silent);
2498 if (!silent)
2499 SendKillObject(new List<uint>() { group.LocalId });
2395 2500
2396// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2501// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2397 } 2502 }
@@ -2681,7 +2786,7 @@ namespace OpenSim.Region.Framework.Scenes
2681 // If the user is banned, we won't let any of their objects 2786 // If the user is banned, we won't let any of their objects
2682 // enter. Period. 2787 // enter. Period.
2683 // 2788 //
2684 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2789 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2685 { 2790 {
2686 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2791 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2687 return false; 2792 return false;
@@ -2717,8 +2822,10 @@ namespace OpenSim.Region.Framework.Scenes
2717 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2822 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2718 newObject.ResumeScripts(); 2823 newObject.ResumeScripts();
2719 2824
2720 if (newObject.RootPart.KeyframeMotion != null) 2825 // AddSceneObject already does this and doing it again messes
2721 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); 2826 // up region crossings, so don't.
2827 //if (newObject.RootPart.KeyframeMotion != null)
2828 // newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2722 } 2829 }
2723 2830
2724 // Do this as late as possible so that listeners have full access to the incoming object 2831 // Do this as late as possible so that listeners have full access to the incoming object
@@ -2736,6 +2843,23 @@ namespace OpenSim.Region.Framework.Scenes
2736 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2843 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2737 public bool AddSceneObject(SceneObjectGroup sceneObject) 2844 public bool AddSceneObject(SceneObjectGroup sceneObject)
2738 { 2845 {
2846 if (sceneObject.OwnerID == UUID.Zero)
2847 {
2848 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2849 return false;
2850 }
2851
2852 // If the user is banned, we won't let any of their objects
2853 // enter. Period.
2854 //
2855 int flags = GetUserFlags(sceneObject.OwnerID);
2856 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2857 {
2858 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2859
2860 return false;
2861 }
2862
2739 // Force allocation of new LocalId 2863 // Force allocation of new LocalId
2740 // 2864 //
2741 SceneObjectPart[] parts = sceneObject.Parts; 2865 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2772,16 +2896,27 @@ namespace OpenSim.Region.Framework.Scenes
2772 // information that this is due to a teleport/border cross rather than an ordinary attachment. 2896 // information that this is due to a teleport/border cross rather than an ordinary attachment.
2773 // We currently do this in Scene.MakeRootAgent() instead. 2897 // We currently do this in Scene.MakeRootAgent() instead.
2774 if (AttachmentsModule != null) 2898 if (AttachmentsModule != null)
2775 AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); 2899 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true);
2776 } 2900 }
2777 else 2901 else
2778 { 2902 {
2903 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2779 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2904 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2780 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2905 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2781 } 2906 }
2907 if (sceneObject.OwnerID == UUID.Zero)
2908 {
2909 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2910 return false;
2911 }
2782 } 2912 }
2783 else 2913 else
2784 { 2914 {
2915 if (sceneObject.OwnerID == UUID.Zero)
2916 {
2917 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2918 return false;
2919 }
2785 AddRestoredSceneObject(sceneObject, true, false); 2920 AddRestoredSceneObject(sceneObject, true, false);
2786 } 2921 }
2787 2922
@@ -2798,6 +2933,24 @@ namespace OpenSim.Region.Framework.Scenes
2798 return 2; // StateSource.PrimCrossing 2933 return 2; // StateSource.PrimCrossing
2799 } 2934 }
2800 2935
2936 public int GetUserFlags(UUID user)
2937 {
2938 //Unfortunately the SP approach means that the value is cached until region is restarted
2939 /*
2940 ScenePresence sp;
2941 if (TryGetScenePresence(user, out sp))
2942 {
2943 return sp.UserFlags;
2944 }
2945 else
2946 {
2947 */
2948 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2949 if (uac == null)
2950 return 0;
2951 return uac.UserFlags;
2952 //}
2953 }
2801 #endregion 2954 #endregion
2802 2955
2803 #region Add/Remove Avatar Methods 2956 #region Add/Remove Avatar Methods
@@ -2831,7 +2984,7 @@ namespace OpenSim.Region.Framework.Scenes
2831 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2984 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2832 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2985 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2833 2986
2834 // CheckHeartbeat(); 2987 CheckHeartbeat();
2835 2988
2836 sp = GetScenePresence(client.AgentId); 2989 sp = GetScenePresence(client.AgentId);
2837 2990
@@ -2849,6 +3002,13 @@ namespace OpenSim.Region.Framework.Scenes
2849 SubscribeToClientEvents(client); 3002 SubscribeToClientEvents(client);
2850 3003
2851 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 3004 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
3005 InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
3006 if (cof == null)
3007 sp.COF = UUID.Zero;
3008 else
3009 sp.COF = cof.ID;
3010
3011 m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
2852 m_eventManager.TriggerOnNewPresence(sp); 3012 m_eventManager.TriggerOnNewPresence(sp);
2853 3013
2854 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 3014 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
@@ -2969,19 +3129,15 @@ namespace OpenSim.Region.Framework.Scenes
2969 // and the scene presence and the client, if they exist 3129 // and the scene presence and the client, if they exist
2970 try 3130 try
2971 { 3131 {
2972 // We need to wait for the client to make UDP contact first. 3132 ScenePresence sp = GetScenePresence(agentID);
2973 // It's the UDP contact that creates the scene presence 3133
2974 ScenePresence sp = WaitGetScenePresence(agentID);
2975 if (sp != null) 3134 if (sp != null)
2976 { 3135 {
2977 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3136 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2978 3137
2979 CloseAgent(sp.UUID, false); 3138 CloseAgent(sp.UUID, false);
2980 } 3139 }
2981 else 3140
2982 {
2983 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2984 }
2985 // BANG! SLASH! 3141 // BANG! SLASH!
2986 m_authenticateHandler.RemoveCircuit(agentID); 3142 m_authenticateHandler.RemoveCircuit(agentID);
2987 3143
@@ -3026,6 +3182,8 @@ namespace OpenSim.Region.Framework.Scenes
3026 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3182 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
3027 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3183 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
3028 3184
3185 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3186
3029 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3187 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
3030 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3188 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
3031 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3189 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -3082,6 +3240,7 @@ namespace OpenSim.Region.Framework.Scenes
3082 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3240 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
3083 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3241 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
3084 client.OnCopyInventoryItem += CopyInventoryItem; 3242 client.OnCopyInventoryItem += CopyInventoryItem;
3243 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
3085 client.OnMoveInventoryItem += MoveInventoryItem; 3244 client.OnMoveInventoryItem += MoveInventoryItem;
3086 client.OnRemoveInventoryItem += RemoveInventoryItem; 3245 client.OnRemoveInventoryItem += RemoveInventoryItem;
3087 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3246 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3151,6 +3310,8 @@ namespace OpenSim.Region.Framework.Scenes
3151 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3310 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3152 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3311 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3153 3312
3313 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3314
3154 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3315 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3155 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3316 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3156 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3317 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3462,7 +3623,7 @@ namespace OpenSim.Region.Framework.Scenes
3462 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3623 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3463 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3624 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3464 if (closeChildAgents && CapsModule != null) 3625 if (closeChildAgents && CapsModule != null)
3465 CapsModule.RemoveCaps(agentID); 3626 CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode);
3466 3627
3467 if (closeChildAgents && !isChildAgent) 3628 if (closeChildAgents && !isChildAgent)
3468 { 3629 {
@@ -3495,6 +3656,7 @@ namespace OpenSim.Region.Framework.Scenes
3495 // It's possible for child agents to have transactions if changes are being made cross-border. 3656 // It's possible for child agents to have transactions if changes are being made cross-border.
3496 if (AgentTransactionsModule != null) 3657 if (AgentTransactionsModule != null)
3497 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3658 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3659 m_log.Debug("[Scene] The avatar has left the building");
3498 } 3660 }
3499 catch (Exception e) 3661 catch (Exception e)
3500 { 3662 {
@@ -3802,13 +3964,16 @@ namespace OpenSim.Region.Framework.Scenes
3802 // On login test land permisions 3964 // On login test land permisions
3803 if (vialogin) 3965 if (vialogin)
3804 { 3966 {
3967 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3968 if (cache != null)
3969 cache.Remove(acd.firstname + " " + acd.lastname);
3805 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) 3970 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y))
3806 { 3971 {
3807 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 3972 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3808 return false; 3973 return false;
3809 } 3974 }
3810 } 3975 }
3811 3976
3812 if (sp == null) // We don't have an [child] agent here already 3977 if (sp == null) // We don't have an [child] agent here already
3813 { 3978 {
3814 if (requirePresenceLookup) 3979 if (requirePresenceLookup)
@@ -3830,7 +3995,7 @@ namespace OpenSim.Region.Framework.Scenes
3830 return false; 3995 return false;
3831 } 3996 }
3832 } 3997 }
3833 3998
3834 try 3999 try
3835 { 4000 {
3836 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) 4001 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason))
@@ -3847,7 +4012,7 @@ namespace OpenSim.Region.Framework.Scenes
3847 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 4012 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3848 return false; 4013 return false;
3849 } 4014 }
3850 4015
3851 m_log.InfoFormat( 4016 m_log.InfoFormat(
3852 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 4017 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3853 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, 4018 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname,
@@ -3856,7 +4021,7 @@ namespace OpenSim.Region.Framework.Scenes
3856 if (CapsModule != null) 4021 if (CapsModule != null)
3857 { 4022 {
3858 CapsModule.SetAgentCapsSeeds(acd); 4023 CapsModule.SetAgentCapsSeeds(acd);
3859 CapsModule.CreateCaps(acd.AgentID); 4024 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3860 } 4025 }
3861 } 4026 }
3862 else 4027 else
@@ -3876,7 +4041,7 @@ namespace OpenSim.Region.Framework.Scenes
3876 if (CapsModule != null) 4041 if (CapsModule != null)
3877 { 4042 {
3878 CapsModule.SetAgentCapsSeeds(acd); 4043 CapsModule.SetAgentCapsSeeds(acd);
3879 CapsModule.CreateCaps(acd.AgentID); 4044 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3880 } 4045 }
3881 } 4046 }
3882 } 4047 }
@@ -3887,6 +4052,11 @@ namespace OpenSim.Region.Framework.Scenes
3887 CacheUserName(null, acd); 4052 CacheUserName(null, acd);
3888 } 4053 }
3889 4054
4055 if (CapsModule != null)
4056 {
4057 CapsModule.ActivateCaps(acd.circuitcode);
4058 }
4059
3890 if (vialogin) 4060 if (vialogin)
3891 { 4061 {
3892// CleanDroppedAttachments(); 4062// CleanDroppedAttachments();
@@ -3978,6 +4148,8 @@ namespace OpenSim.Region.Framework.Scenes
3978 } 4148 }
3979 4149
3980 // Honor parcel landing type and position. 4150 // Honor parcel landing type and position.
4151 /*
4152 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3981 if (land != null) 4153 if (land != null)
3982 { 4154 {
3983 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 4155 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3985,6 +4157,7 @@ namespace OpenSim.Region.Framework.Scenes
3985 acd.startpos = land.LandData.UserLocation; 4157 acd.startpos = land.LandData.UserLocation;
3986 } 4158 }
3987 } 4159 }
4160 */// This is now handled properly in ScenePresence.MakeRootAgent
3988 } 4161 }
3989 4162
3990 return true; 4163 return true;
@@ -4082,7 +4255,7 @@ namespace OpenSim.Region.Framework.Scenes
4082 4255
4083 if (!m_strictAccessControl) return true; 4256 if (!m_strictAccessControl) return true;
4084 if (Permissions.IsGod(agent.AgentID)) return true; 4257 if (Permissions.IsGod(agent.AgentID)) return true;
4085 4258
4086 if (AuthorizationService != null) 4259 if (AuthorizationService != null)
4087 { 4260 {
4088 if (!AuthorizationService.IsAuthorizedForRegion( 4261 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -4103,7 +4276,8 @@ namespace OpenSim.Region.Framework.Scenes
4103 { 4276 {
4104 if (RegionInfo.EstateSettings != null) 4277 if (RegionInfo.EstateSettings != null)
4105 { 4278 {
4106 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4279 int flags = GetUserFlags(agent.AgentID);
4280 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, flags))
4107 { 4281 {
4108 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4282 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
4109 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4283 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4292,6 +4466,15 @@ namespace OpenSim.Region.Framework.Scenes
4292 m_log.DebugFormat( 4466 m_log.DebugFormat(
4293 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 4467 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
4294 4468
4469 // We have to wait until the viewer contacts this region after receiving EAC.
4470 // That calls AddNewClient, which finally creates the ScenePresence
4471 int flags = GetUserFlags(cAgentData.AgentID);
4472 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4473 {
4474 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4475 return false;
4476 }
4477
4295 // TODO: This check should probably be in QueryAccess(). 4478 // TODO: This check should probably be in QueryAccess().
4296 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4479 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4297 if (nearestParcel == null) 4480 if (nearestParcel == null)
@@ -4392,7 +4575,7 @@ namespace OpenSim.Region.Framework.Scenes
4392 /// <param name='agentID'></param> 4575 /// <param name='agentID'></param>
4393 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4576 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4394 { 4577 {
4395 int ntimes = 20; 4578 int ntimes = 30;
4396 ScenePresence sp = null; 4579 ScenePresence sp = null;
4397 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4580 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4398 Thread.Sleep(1000); 4581 Thread.Sleep(1000);
@@ -4454,6 +4637,16 @@ namespace OpenSim.Region.Framework.Scenes
4454 return false; 4637 return false;
4455 } 4638 }
4456 4639
4640// public bool IncomingCloseAgent(UUID agentID)
4641// {
4642// return IncomingCloseAgent(agentID, false);
4643// }
4644
4645// public bool IncomingCloseChildAgent(UUID agentID)
4646// {
4647// return IncomingCloseAgent(agentID, true);
4648// }
4649
4457 /// <summary> 4650 /// <summary>
4458 /// Tell a single client to prepare to close. 4651 /// Tell a single client to prepare to close.
4459 /// </summary> 4652 /// </summary>
@@ -4552,7 +4745,7 @@ namespace OpenSim.Region.Framework.Scenes
4552 4745
4553 if (sp != null) 4746 if (sp != null)
4554 { 4747 {
4555 sp.ControllingClient.Close(force); 4748 sp.ControllingClient.Close(force, force);
4556 return true; 4749 return true;
4557 } 4750 }
4558 4751
@@ -5170,7 +5363,7 @@ namespace OpenSim.Region.Framework.Scenes
5170 { 5363 {
5171 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 5364 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
5172 { 5365 {
5173 if (grp.RootPart.Expires <= DateTime.Now) 5366 if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now)
5174 DeleteSceneObject(grp, false); 5367 DeleteSceneObject(grp, false);
5175 } 5368 }
5176 } 5369 }
@@ -5184,35 +5377,81 @@ namespace OpenSim.Region.Framework.Scenes
5184 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5377 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
5185 } 5378 }
5186 5379
5187 public int GetHealth() 5380 public int GetHealth(out int flags, out string message)
5188 { 5381 {
5189 // Returns: 5382 // Returns:
5190 // 1 = sim is up and accepting http requests. The heartbeat has 5383 // 1 = sim is up and accepting http requests. The heartbeat has
5191 // stopped and the sim is probably locked up, but a remote 5384 // stopped and the sim is probably locked up, but a remote
5192 // admin restart may succeed 5385 // admin restart may succeed
5193 // 5386 //
5194 // 2 = Sim is up and the heartbeat is running. The sim is likely 5387 // 2 = Sim is up and the heartbeat is running. The sim is likely
5195 // usable for people within and logins _may_ work 5388 // usable for people within
5389 //
5390 // 3 = Sim is up and one packet thread is running. Sim is
5391 // unstable and will not accept new logins
5196 // 5392 //
5197 // 3 = We have seen a new user enter within the past 4 minutes 5393 // 4 = Sim is up and both packet threads are running. Sim is
5394 // likely usable
5395 //
5396 // 5 = We have seen a new user enter within the past 4 minutes
5198 // which can be seen as positive confirmation of sim health 5397 // which can be seen as positive confirmation of sim health
5199 // 5398 //
5399
5400 flags = 0;
5401 message = String.Empty;
5402
5403 CheckHeartbeat();
5404
5405 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5406 {
5407 // We're still starting
5408 // 0 means "in startup", it can't happen another way, since
5409 // to get here, we must be able to accept http connections
5410 return 0;
5411 }
5412
5200 int health=1; // Start at 1, means we're up 5413 int health=1; // Start at 1, means we're up
5201 5414
5202 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5415 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
5203 health += 1; 5416 {
5417 health+=1;
5418 flags |= 1;
5419 }
5420
5421 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5422 {
5423 health+=1;
5424 flags |= 2;
5425 }
5426
5427 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5428 {
5429 health+=1;
5430 flags |= 4;
5431 }
5204 else 5432 else
5433 {
5434int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5435System.Diagnostics.Process proc = new System.Diagnostics.Process();
5436proc.EnableRaisingEvents=false;
5437proc.StartInfo.FileName = "/bin/kill";
5438proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5439proc.Start();
5440proc.WaitForExit();
5441Thread.Sleep(1000);
5442Environment.Exit(1);
5443 }
5444
5445 if (flags != 7)
5205 return health; 5446 return health;
5206 5447
5207 // A login in the last 4 mins? We can't be doing too badly 5448 // A login in the last 4 mins? We can't be doing too badly
5208 // 5449 //
5209 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5450 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
5210 health++; 5451 health++;
5211 else 5452 else
5212 return health; 5453 return health;
5213 5454
5214// CheckHeartbeat();
5215
5216 return health; 5455 return health;
5217 } 5456 }
5218 5457
@@ -5300,7 +5539,7 @@ namespace OpenSim.Region.Framework.Scenes
5300 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5539 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5301 if (wasUsingPhysics) 5540 if (wasUsingPhysics)
5302 { 5541 {
5303 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 5542 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
5304 } 5543 }
5305 } 5544 }
5306 5545
@@ -5399,14 +5638,14 @@ namespace OpenSim.Region.Framework.Scenes
5399 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5638 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5400 } 5639 }
5401 5640
5402// private void CheckHeartbeat() 5641 private void CheckHeartbeat()
5403// { 5642 {
5404// if (m_firstHeartbeat) 5643 if (m_firstHeartbeat)
5405// return; 5644 return;
5406// 5645
5407// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5646 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5408// StartTimer(); 5647 Start();
5409// } 5648 }
5410 5649
5411 public override ISceneObject DeserializeObject(string representation) 5650 public override ISceneObject DeserializeObject(string representation)
5412 { 5651 {
@@ -5464,7 +5703,7 @@ namespace OpenSim.Region.Framework.Scenes
5464 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); 5703 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
5465 5704
5466 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); 5705 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
5467 5706
5468 return nearestRegionEdgePoint; 5707 return nearestRegionEdgePoint;
5469 } 5708 }
5470 5709
@@ -5718,7 +5957,55 @@ namespace OpenSim.Region.Framework.Scenes
5718 mapModule.GenerateMaptile(); 5957 mapModule.GenerateMaptile();
5719 } 5958 }
5720 5959
5721 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5960// public void CleanDroppedAttachments()
5961// {
5962// List<SceneObjectGroup> objectsToDelete =
5963// new List<SceneObjectGroup>();
5964//
5965// lock (m_cleaningAttachments)
5966// {
5967// ForEachSOG(delegate (SceneObjectGroup grp)
5968// {
5969// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5970// {
5971// UUID agentID = grp.OwnerID;
5972// if (agentID == UUID.Zero)
5973// {
5974// objectsToDelete.Add(grp);
5975// return;
5976// }
5977//
5978// ScenePresence sp = GetScenePresence(agentID);
5979// if (sp == null)
5980// {
5981// objectsToDelete.Add(grp);
5982// return;
5983// }
5984// }
5985// });
5986// }
5987//
5988// foreach (SceneObjectGroup grp in objectsToDelete)
5989// {
5990// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5991// DeleteSceneObject(grp, true);
5992// }
5993// }
5994
5995 public void ThreadAlive(int threadCode)
5996 {
5997 switch(threadCode)
5998 {
5999 case 1: // Incoming
6000 m_lastIncoming = Util.EnvironmentTickCount();
6001 break;
6002 case 2: // Incoming
6003 m_lastOutgoing = Util.EnvironmentTickCount();
6004 break;
6005 }
6006 }
6007
6008 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5722 { 6009 {
5723 RegenerateMaptile(); 6010 RegenerateMaptile();
5724 6011
@@ -5869,7 +6156,19 @@ namespace OpenSim.Region.Framework.Scenes
5869 return true; 6156 return true;
5870 } 6157 }
5871 6158
5872 /// <summary> 6159 public void StartTimerWatchdog()
6160 {
6161 m_timerWatchdog.Interval = 1000;
6162 m_timerWatchdog.Elapsed += TimerWatchdog;
6163 m_timerWatchdog.AutoReset = true;
6164 m_timerWatchdog.Start();
6165 }
6166
6167 public void TimerWatchdog(object sender, ElapsedEventArgs e)
6168 {
6169 CheckHeartbeat();
6170 }
6171
5873 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 6172 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5874 /// autopilot that moves an avatar to a sit target!. 6173 /// autopilot that moves an avatar to a sit target!.
5875 /// </summary> 6174 /// </summary>
@@ -5948,6 +6247,11 @@ namespace OpenSim.Region.Framework.Scenes
5948 return m_SpawnPoint - 1; 6247 return m_SpawnPoint - 1;
5949 } 6248 }
5950 6249
6250 private void HandleGcCollect(string module, string[] args)
6251 {
6252 GC.Collect();
6253 }
6254
5951 /// <summary> 6255 /// <summary>
5952 /// Wrappers to get physics modules retrieve assets. 6256 /// Wrappers to get physics modules retrieve assets.
5953 /// </summary> 6257 /// </summary>