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.cs517
1 files changed, 409 insertions, 108 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d187377..4fa4a7c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -227,8 +227,8 @@ namespace OpenSim.Region.Framework.Scenes
227 // TODO: need to figure out how allow client agents but deny 227 // TODO: need to figure out how allow client agents but deny
228 // root agents when ACL denies access to root agent 228 // root agents when ACL denies access to root agent
229 public bool m_strictAccessControl = true; 229 public bool m_strictAccessControl = true;
230 230 public bool m_seeIntoBannedRegion = false;
231 public int MaxUndoCount { get; set; } 231 public int MaxUndoCount = 5;
232 232
233 public bool SeeIntoRegion { get; set; } 233 public bool SeeIntoRegion { get; set; }
234 234
@@ -246,11 +246,13 @@ namespace OpenSim.Region.Framework.Scenes
246 246
247 protected int m_splitRegionID; 247 protected int m_splitRegionID;
248 protected Timer m_restartWaitTimer = new Timer(); 248 protected Timer m_restartWaitTimer = new Timer();
249 protected Timer m_timerWatchdog = new Timer();
249 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 250 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
250 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 251 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
251 protected string m_simulatorVersion = "OpenSimulator Server"; 252 protected string m_simulatorVersion = "OpenSimulator Server";
252 protected AgentCircuitManager m_authenticateHandler; 253 protected AgentCircuitManager m_authenticateHandler;
253 protected SceneCommunicationService m_sceneGridService; 254 protected SceneCommunicationService m_sceneGridService;
255 protected ISnmpModule m_snmpService = null;
254 256
255 protected ISimulationDataService m_SimulationDataService; 257 protected ISimulationDataService m_SimulationDataService;
256 protected IEstateDataService m_EstateDataService; 258 protected IEstateDataService m_EstateDataService;
@@ -313,8 +315,8 @@ namespace OpenSim.Region.Framework.Scenes
313 private int m_update_presences = 1; // Update scene presence movements 315 private int m_update_presences = 1; // Update scene presence movements
314 private int m_update_events = 1; 316 private int m_update_events = 1;
315 private int m_update_backup = 200; 317 private int m_update_backup = 200;
316 private int m_update_terrain = 50; 318 private int m_update_terrain = 1000;
317// private int m_update_land = 1; 319 private int m_update_land = 10;
318 private int m_update_coarse_locations = 50; 320 private int m_update_coarse_locations = 50;
319 321
320 private int agentMS; 322 private int agentMS;
@@ -327,13 +329,13 @@ namespace OpenSim.Region.Framework.Scenes
327 private int backupMS; 329 private int backupMS;
328 private int terrainMS; 330 private int terrainMS;
329 private int landMS; 331 private int landMS;
330 private int spareMS;
331 332
332 /// <summary> 333 /// <summary>
333 /// Tick at which the last frame was processed. 334 /// Tick at which the last frame was processed.
334 /// </summary> 335 /// </summary>
335 private int m_lastFrameTick; 336 private int m_lastFrameTick;
336 337
338 public bool CombineRegions = false;
337 /// <summary> 339 /// <summary>
338 /// Tick at which the last maintenance run occurred. 340 /// Tick at which the last maintenance run occurred.
339 /// </summary> 341 /// </summary>
@@ -353,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes
353 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 355 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
354 private volatile bool m_backingup; 356 private volatile bool m_backingup;
355 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 357 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
356 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); 358 private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>();
357 359
358 private string m_defaultScriptEngine; 360 private string m_defaultScriptEngine;
359 361
@@ -362,6 +364,11 @@ namespace OpenSim.Region.Framework.Scenes
362 /// </summary> 364 /// </summary>
363 private int m_LastLogin; 365 private int m_LastLogin;
364 366
367 private int m_lastIncoming;
368 private int m_lastOutgoing;
369 private int m_hbRestarts = 0;
370
371
365 /// <summary> 372 /// <summary>
366 /// Thread that runs the scene loop. 373 /// Thread that runs the scene loop.
367 /// </summary> 374 /// </summary>
@@ -404,7 +411,7 @@ namespace OpenSim.Region.Framework.Scenes
404 private volatile bool m_active; 411 private volatile bool m_active;
405 412
406// private int m_lastUpdate; 413// private int m_lastUpdate;
407// private bool m_firstHeartbeat = true; 414 private bool m_firstHeartbeat = true;
408 415
409 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 416 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
410 private bool m_reprioritizationEnabled = true; 417 private bool m_reprioritizationEnabled = true;
@@ -448,6 +455,19 @@ namespace OpenSim.Region.Framework.Scenes
448 get { return m_sceneGridService; } 455 get { return m_sceneGridService; }
449 } 456 }
450 457
458 public ISnmpModule SnmpService
459 {
460 get
461 {
462 if (m_snmpService == null)
463 {
464 m_snmpService = RequestModuleInterface<ISnmpModule>();
465 }
466
467 return m_snmpService;
468 }
469 }
470
451 public ISimulationDataService SimulationDataService 471 public ISimulationDataService SimulationDataService
452 { 472 {
453 get 473 get
@@ -740,6 +760,8 @@ namespace OpenSim.Region.Framework.Scenes
740 m_SimulationDataService = simDataService; 760 m_SimulationDataService = simDataService;
741 m_EstateDataService = estateDataService; 761 m_EstateDataService = estateDataService;
742 m_regionHandle = RegionInfo.RegionHandle; 762 m_regionHandle = RegionInfo.RegionHandle;
763 m_lastIncoming = 0;
764 m_lastOutgoing = 0;
743 765
744 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 766 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
745 m_asyncSceneObjectDeleter.Enabled = true; 767 m_asyncSceneObjectDeleter.Enabled = true;
@@ -833,7 +855,7 @@ namespace OpenSim.Region.Framework.Scenes
833 855
834 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 856 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
835 857
836 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); 858 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
837 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); 859 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
838 if (!UseBackup) 860 if (!UseBackup)
839 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); 861 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
@@ -841,13 +863,11 @@ namespace OpenSim.Region.Framework.Scenes
841 //Animation states 863 //Animation states
842 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 864 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
843 865
844 SeeIntoRegion = startupConfig.GetBoolean("see_into_region", true);
845 866
846 MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); 867 MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20);
847 868
848 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); 869 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
849 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); 870 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
850
851 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); 871 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
852 if (RegionInfo.NonphysPrimMin > 0) 872 if (RegionInfo.NonphysPrimMin > 0)
853 { 873 {
@@ -867,11 +887,21 @@ namespace OpenSim.Region.Framework.Scenes
867 } 887 }
868 888
869 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 889 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
890
870 if (RegionInfo.PhysPrimMax > 0) 891 if (RegionInfo.PhysPrimMax > 0)
871 { 892 {
872 m_maxPhys = RegionInfo.PhysPrimMax; 893 m_maxPhys = RegionInfo.PhysPrimMax;
873 } 894 }
874 895
896 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
897 if (RegionInfo.LinksetCapacity > 0)
898 {
899 m_linksetCapacity = RegionInfo.LinksetCapacity;
900 }
901
902 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
903 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
904
875 // Here, if clamping is requested in either global or 905 // Here, if clamping is requested in either global or
876 // local config, it will be used 906 // local config, it will be used
877 // 907 //
@@ -881,13 +911,7 @@ namespace OpenSim.Region.Framework.Scenes
881 m_clampPrimSize = true; 911 m_clampPrimSize = true;
882 } 912 }
883 913
884 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 914 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
885 if (RegionInfo.LinksetCapacity > 0)
886 {
887 m_linksetCapacity = RegionInfo.LinksetCapacity;
888 }
889
890 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete);
891 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 915 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
892 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 916 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
893 m_dontPersistBefore = 917 m_dontPersistBefore =
@@ -898,11 +922,11 @@ namespace OpenSim.Region.Framework.Scenes
898 m_persistAfter *= 10000000; 922 m_persistAfter *= 10000000;
899 923
900 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 924 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
901 925 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
902 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
903 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
904 926
905 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 927 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
928 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
929 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
906 930
907 string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; 931 string[] possibleMapConfigSections = new string[] { "Map", "Startup" };
908 932
@@ -947,7 +971,7 @@ namespace OpenSim.Region.Framework.Scenes
947 971
948 if (grant.Length > 0) 972 if (grant.Length > 0)
949 { 973 {
950 foreach (string viewer in grant.Split('|')) 974 foreach (string viewer in grant.Split(','))
951 { 975 {
952 m_AllowedViewers.Add(viewer.Trim().ToLower()); 976 m_AllowedViewers.Add(viewer.Trim().ToLower());
953 } 977 }
@@ -959,7 +983,7 @@ namespace OpenSim.Region.Framework.Scenes
959 983
960 if (grant.Length > 0) 984 if (grant.Length > 0)
961 { 985 {
962 foreach (string viewer in grant.Split('|')) 986 foreach (string viewer in grant.Split(','))
963 { 987 {
964 m_BannedViewers.Add(viewer.Trim().ToLower()); 988 m_BannedViewers.Add(viewer.Trim().ToLower());
965 } 989 }
@@ -1019,6 +1043,8 @@ namespace OpenSim.Region.Framework.Scenes
1019 StatsReporter = new SimStatsReporter(this); 1043 StatsReporter = new SimStatsReporter(this);
1020 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 1044 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
1021 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 1045 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
1046
1047 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
1022 } 1048 }
1023 1049
1024 public Scene(RegionInfo regInfo) : base(regInfo) 1050 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1314,8 +1340,11 @@ namespace OpenSim.Region.Framework.Scenes
1314 // Stop all client threads. 1340 // Stop all client threads.
1315 ForEachScenePresence(delegate(ScenePresence avatar) { IncomingCloseAgent(avatar.UUID, false); }); 1341 ForEachScenePresence(delegate(ScenePresence avatar) { IncomingCloseAgent(avatar.UUID, false); });
1316 1342
1317 m_log.Debug("[SCENE]: Persisting changed objects"); 1343 m_log.Debug("[SCENE]: TriggerSceneShuttingDown");
1318 EventManager.TriggerSceneShuttingDown(this); 1344 EventManager.TriggerSceneShuttingDown(this);
1345
1346 m_log.Debug("[SCENE]: Persisting changed objects");
1347
1319 Backup(false); 1348 Backup(false);
1320 m_sceneGraph.Close(); 1349 m_sceneGraph.Close();
1321 1350
@@ -1329,6 +1358,7 @@ namespace OpenSim.Region.Framework.Scenes
1329 // attempt to reference a null or disposed physics scene. 1358 // attempt to reference a null or disposed physics scene.
1330 if (PhysicsScene != null) 1359 if (PhysicsScene != null)
1331 { 1360 {
1361 m_log.Debug("[SCENE]: Dispose Physics");
1332 PhysicsScene phys = PhysicsScene; 1362 PhysicsScene phys = PhysicsScene;
1333 // remove the physics engine from both Scene and SceneGraph 1363 // remove the physics engine from both Scene and SceneGraph
1334 PhysicsScene = null; 1364 PhysicsScene = null;
@@ -1359,11 +1389,29 @@ namespace OpenSim.Region.Framework.Scenes
1359 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1389 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1360 if (m_heartbeatThread != null) 1390 if (m_heartbeatThread != null)
1361 { 1391 {
1392 m_hbRestarts++;
1393 if(m_hbRestarts > 10)
1394 Environment.Exit(1);
1395 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1396
1397//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1398//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1399//proc.EnableRaisingEvents=false;
1400//proc.StartInfo.FileName = "/bin/kill";
1401//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1402//proc.Start();
1403//proc.WaitForExit();
1404//Thread.Sleep(1000);
1405//Environment.Exit(1);
1362 m_heartbeatThread.Abort(); 1406 m_heartbeatThread.Abort();
1407 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1363 m_heartbeatThread = null; 1408 m_heartbeatThread = null;
1364 } 1409 }
1365// m_lastUpdate = Util.EnvironmentTickCount(); 1410// m_lastUpdate = Util.EnvironmentTickCount();
1366 1411
1412// m_sceneGraph.PreparePhysicsSimulation();
1413
1414
1367 m_heartbeatThread 1415 m_heartbeatThread
1368 = Watchdog.StartThread( 1416 = Watchdog.StartThread(
1369 Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); 1417 Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false);
@@ -1508,16 +1556,20 @@ namespace OpenSim.Region.Framework.Scenes
1508 endFrame = Frame + frames; 1556 endFrame = Frame + frames;
1509 1557
1510 float physicsFPS = 0f; 1558 float physicsFPS = 0f;
1511 int previousFrameTick, tmpMS; 1559 int tmpMS;
1512 int maintc = Util.EnvironmentTickCount(); 1560 int previousFrameTick;
1561 int maintc;
1562 int sleepMS;
1563 int framestart;
1513 1564
1514 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1565 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1515 { 1566 {
1567 framestart = Util.EnvironmentTickCount();
1516 ++Frame; 1568 ++Frame;
1517 1569
1518// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1570// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1519 1571
1520 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1572 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1521 1573
1522 try 1574 try
1523 { 1575 {
@@ -1571,6 +1623,7 @@ namespace OpenSim.Region.Framework.Scenes
1571 m_sceneGraph.UpdatePresences(); 1623 m_sceneGraph.UpdatePresences();
1572 1624
1573 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1625 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1626
1574 1627
1575 // Delete temp-on-rez stuff 1628 // Delete temp-on-rez stuff
1576 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1629 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1652,34 +1705,37 @@ namespace OpenSim.Region.Framework.Scenes
1652 1705
1653 Watchdog.UpdateThread(); 1706 Watchdog.UpdateThread();
1654 1707
1708 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1709
1710 StatsReporter.AddPhysicsFPS(physicsFPS);
1711 StatsReporter.AddTimeDilation(TimeDilation);
1712 StatsReporter.AddFPS(1);
1713
1714 StatsReporter.addAgentMS(agentMS);
1715 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1716 StatsReporter.addOtherMS(otherMS);
1717 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1718
1655 previousFrameTick = m_lastFrameTick; 1719 previousFrameTick = m_lastFrameTick;
1656 m_lastFrameTick = Util.EnvironmentTickCount(); 1720 m_lastFrameTick = Util.EnvironmentTickCount();
1657 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1721 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1658 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1722 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1659 1723
1724 m_firstHeartbeat = false;
1725
1726 sleepMS = Util.EnvironmentTickCount();
1727
1660 if (tmpMS > 0) 1728 if (tmpMS > 0)
1661 {
1662 Thread.Sleep(tmpMS); 1729 Thread.Sleep(tmpMS);
1663 spareMS += tmpMS;
1664 }
1665 1730
1666 frameMS = Util.EnvironmentTickCountSubtract(maintc); 1731 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1667 maintc = Util.EnvironmentTickCount(); 1732 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1668 1733 StatsReporter.addSleepMS(sleepMS);
1669 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1734 StatsReporter.addFrameMS(frameMS);
1670 1735
1671 // if (Frame%m_update_avatars == 0) 1736 // if (Frame%m_update_avatars == 0)
1672 // UpdateInWorldTime(); 1737 // UpdateInWorldTime();
1673 StatsReporter.AddPhysicsFPS(physicsFPS);
1674 StatsReporter.AddTimeDilation(TimeDilation);
1675 StatsReporter.AddFPS(1);
1676 1738
1677 StatsReporter.addFrameMS(frameMS);
1678 StatsReporter.addAgentMS(agentMS);
1679 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1680 StatsReporter.addOtherMS(otherMS);
1681 StatsReporter.AddSpareMS(spareMS);
1682 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1683 1739
1684 // Optionally warn if a frame takes double the amount of time that it should. 1740 // Optionally warn if a frame takes double the amount of time that it should.
1685 if (DebugUpdates 1741 if (DebugUpdates
@@ -1696,7 +1752,7 @@ namespace OpenSim.Region.Framework.Scenes
1696 public void AddGroupTarget(SceneObjectGroup grp) 1752 public void AddGroupTarget(SceneObjectGroup grp)
1697 { 1753 {
1698 lock (m_groupsWithTargets) 1754 lock (m_groupsWithTargets)
1699 m_groupsWithTargets[grp.UUID] = grp; 1755 m_groupsWithTargets[grp.UUID] = 0;
1700 } 1756 }
1701 1757
1702 public void RemoveGroupTarget(SceneObjectGroup grp) 1758 public void RemoveGroupTarget(SceneObjectGroup grp)
@@ -1707,18 +1763,24 @@ namespace OpenSim.Region.Framework.Scenes
1707 1763
1708 private void CheckAtTargets() 1764 private void CheckAtTargets()
1709 { 1765 {
1710 List<SceneObjectGroup> objs = null; 1766 List<UUID> objs = null;
1711 1767
1712 lock (m_groupsWithTargets) 1768 lock (m_groupsWithTargets)
1713 { 1769 {
1714 if (m_groupsWithTargets.Count != 0) 1770 if (m_groupsWithTargets.Count != 0)
1715 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); 1771 objs = new List<UUID>(m_groupsWithTargets.Keys);
1716 } 1772 }
1717 1773
1718 if (objs != null) 1774 if (objs != null)
1719 { 1775 {
1720 foreach (SceneObjectGroup entry in objs) 1776 foreach (UUID entry in objs)
1721 entry.checkAtTargets(); 1777 {
1778 SceneObjectGroup grp = GetSceneObjectGroup(entry);
1779 if (grp == null)
1780 m_groupsWithTargets.Remove(entry);
1781 else
1782 grp.checkAtTargets();
1783 }
1722 } 1784 }
1723 } 1785 }
1724 1786
@@ -1797,7 +1859,7 @@ namespace OpenSim.Region.Framework.Scenes
1797 msg.fromAgentName = "Server"; 1859 msg.fromAgentName = "Server";
1798 msg.dialog = (byte)19; // Object msg 1860 msg.dialog = (byte)19; // Object msg
1799 msg.fromGroup = false; 1861 msg.fromGroup = false;
1800 msg.offline = (byte)0; 1862 msg.offline = (byte)1;
1801 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1863 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1802 msg.Position = Vector3.Zero; 1864 msg.Position = Vector3.Zero;
1803 msg.RegionID = RegionInfo.RegionID.Guid; 1865 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -2026,7 +2088,7 @@ namespace OpenSim.Region.Framework.Scenes
2026 return PhysicsScene.SupportsRaycastWorldFiltered(); 2088 return PhysicsScene.SupportsRaycastWorldFiltered();
2027 } 2089 }
2028 2090
2029 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) 2091 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2030 { 2092 {
2031 if (PhysicsScene == null) 2093 if (PhysicsScene == null)
2032 return null; 2094 return null;
@@ -2048,14 +2110,24 @@ namespace OpenSim.Region.Framework.Scenes
2048 /// <returns></returns> 2110 /// <returns></returns>
2049 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2111 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
2050 { 2112 {
2113
2114 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2115 Vector3 wpos = Vector3.Zero;
2116 // Check for water surface intersection from above
2117 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2118 {
2119 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2120 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2121 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2122 wpos.Z = wheight;
2123 }
2124
2051 Vector3 pos = Vector3.Zero; 2125 Vector3 pos = Vector3.Zero;
2052 if (RayEndIsIntersection == (byte)1) 2126 if (RayEndIsIntersection == (byte)1)
2053 { 2127 {
2054 pos = RayEnd; 2128 pos = RayEnd;
2055 return pos;
2056 } 2129 }
2057 2130 else if (RayTargetID != UUID.Zero)
2058 if (RayTargetID != UUID.Zero)
2059 { 2131 {
2060 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2132 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
2061 2133
@@ -2077,7 +2149,7 @@ namespace OpenSim.Region.Framework.Scenes
2077 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2149 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2078 2150
2079 // Un-comment out the following line to Get Raytrace results printed to the console. 2151 // Un-comment out the following line to Get Raytrace results printed to the console.
2080 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2152 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2081 float ScaleOffset = 0.5f; 2153 float ScaleOffset = 0.5f;
2082 2154
2083 // If we hit something 2155 // If we hit something
@@ -2100,13 +2172,10 @@ namespace OpenSim.Region.Framework.Scenes
2100 //pos.Z -= 0.25F; 2172 //pos.Z -= 0.25F;
2101 2173
2102 } 2174 }
2103
2104 return pos;
2105 } 2175 }
2106 else 2176 else
2107 { 2177 {
2108 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2178 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2109
2110 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2179 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2111 2180
2112 // Un-comment the following line to print the raytrace results to the console. 2181 // Un-comment the following line to print the raytrace results to the console.
@@ -2115,13 +2184,12 @@ namespace OpenSim.Region.Framework.Scenes
2115 if (ei.HitTF) 2184 if (ei.HitTF)
2116 { 2185 {
2117 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2186 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2118 } else 2187 }
2188 else
2119 { 2189 {
2120 // fall back to our stupid functionality 2190 // fall back to our stupid functionality
2121 pos = RayEnd; 2191 pos = RayEnd;
2122 } 2192 }
2123
2124 return pos;
2125 } 2193 }
2126 } 2194 }
2127 else 2195 else
@@ -2132,8 +2200,12 @@ namespace OpenSim.Region.Framework.Scenes
2132 //increase height so its above the ground. 2200 //increase height so its above the ground.
2133 //should be getting the normal of the ground at the rez point and using that? 2201 //should be getting the normal of the ground at the rez point and using that?
2134 pos.Z += scale.Z / 2f; 2202 pos.Z += scale.Z / 2f;
2135 return pos; 2203// return pos;
2136 } 2204 }
2205
2206 // check against posible water intercept
2207 if (wpos.Z > pos.Z) pos = wpos;
2208 return pos;
2137 } 2209 }
2138 2210
2139 2211
@@ -2224,12 +2296,12 @@ namespace OpenSim.Region.Framework.Scenes
2224 { 2296 {
2225 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) 2297 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2226 { 2298 {
2299 sceneObject.IsDeleted = false;
2227 EventManager.TriggerObjectAddedToScene(sceneObject); 2300 EventManager.TriggerObjectAddedToScene(sceneObject);
2228 return true; 2301 return true;
2229 } 2302 }
2230 2303
2231 return false; 2304 return false;
2232
2233 } 2305 }
2234 2306
2235 /// <summary> 2307 /// <summary>
@@ -2321,6 +2393,15 @@ namespace OpenSim.Region.Framework.Scenes
2321 /// </summary> 2393 /// </summary>
2322 public void DeleteAllSceneObjects() 2394 public void DeleteAllSceneObjects()
2323 { 2395 {
2396 DeleteAllSceneObjects(false);
2397 }
2398
2399 /// <summary>
2400 /// Delete every object from the scene. This does not include attachments worn by avatars.
2401 /// </summary>
2402 public void DeleteAllSceneObjects(bool exceptNoCopy)
2403 {
2404 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2324 lock (Entities) 2405 lock (Entities)
2325 { 2406 {
2326 EntityBase[] entities = Entities.GetEntities(); 2407 EntityBase[] entities = Entities.GetEntities();
@@ -2329,11 +2410,24 @@ namespace OpenSim.Region.Framework.Scenes
2329 if (e is SceneObjectGroup) 2410 if (e is SceneObjectGroup)
2330 { 2411 {
2331 SceneObjectGroup sog = (SceneObjectGroup)e; 2412 SceneObjectGroup sog = (SceneObjectGroup)e;
2332 if (!sog.IsAttachment) 2413 if (sog != null && !sog.IsAttachment)
2333 DeleteSceneObject((SceneObjectGroup)e, false); 2414 {
2415 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2416 {
2417 DeleteSceneObject((SceneObjectGroup)e, false);
2418 }
2419 else
2420 {
2421 toReturn.Add((SceneObjectGroup)e);
2422 }
2423 }
2334 } 2424 }
2335 } 2425 }
2336 } 2426 }
2427 if (toReturn.Count > 0)
2428 {
2429 returnObjects(toReturn.ToArray(), UUID.Zero);
2430 }
2337 } 2431 }
2338 2432
2339 /// <summary> 2433 /// <summary>
@@ -2364,6 +2458,14 @@ namespace OpenSim.Region.Framework.Scenes
2364 else 2458 else
2365 group.StopScriptInstances(); 2459 group.StopScriptInstances();
2366 2460
2461 List<UUID> avatars = group.GetSittingAvatars();
2462 foreach (UUID av in avatars)
2463 {
2464 ScenePresence p = GetScenePresence(av);
2465 if (p != null)
2466 p.StandUp();
2467 }
2468
2367 SceneObjectPart[] partList = group.Parts; 2469 SceneObjectPart[] partList = group.Parts;
2368 2470
2369 foreach (SceneObjectPart part in partList) 2471 foreach (SceneObjectPart part in partList)
@@ -2391,6 +2493,8 @@ namespace OpenSim.Region.Framework.Scenes
2391 } 2493 }
2392 2494
2393 group.DeleteGroupFromScene(silent); 2495 group.DeleteGroupFromScene(silent);
2496 if (!silent)
2497 SendKillObject(new List<uint>() { group.LocalId });
2394 2498
2395// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2499// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2396 } 2500 }
@@ -2680,7 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes
2680 // If the user is banned, we won't let any of their objects 2784 // If the user is banned, we won't let any of their objects
2681 // enter. Period. 2785 // enter. Period.
2682 // 2786 //
2683 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2787 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2684 { 2788 {
2685 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2789 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2686 return false; 2790 return false;
@@ -2735,6 +2839,23 @@ namespace OpenSim.Region.Framework.Scenes
2735 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2839 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2736 public bool AddSceneObject(SceneObjectGroup sceneObject) 2840 public bool AddSceneObject(SceneObjectGroup sceneObject)
2737 { 2841 {
2842 if (sceneObject.OwnerID == UUID.Zero)
2843 {
2844 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2845 return false;
2846 }
2847
2848 // If the user is banned, we won't let any of their objects
2849 // enter. Period.
2850 //
2851 int flags = GetUserFlags(sceneObject.OwnerID);
2852 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2853 {
2854 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2855
2856 return false;
2857 }
2858
2738 // Force allocation of new LocalId 2859 // Force allocation of new LocalId
2739 // 2860 //
2740 SceneObjectPart[] parts = sceneObject.Parts; 2861 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2771,16 +2892,27 @@ namespace OpenSim.Region.Framework.Scenes
2771 // information that this is due to a teleport/border cross rather than an ordinary attachment. 2892 // information that this is due to a teleport/border cross rather than an ordinary attachment.
2772 // We currently do this in Scene.MakeRootAgent() instead. 2893 // We currently do this in Scene.MakeRootAgent() instead.
2773 if (AttachmentsModule != null) 2894 if (AttachmentsModule != null)
2774 AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); 2895 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true);
2775 } 2896 }
2776 else 2897 else
2777 { 2898 {
2899 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2778 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2900 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2779 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2901 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2780 } 2902 }
2903 if (sceneObject.OwnerID == UUID.Zero)
2904 {
2905 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2906 return false;
2907 }
2781 } 2908 }
2782 else 2909 else
2783 { 2910 {
2911 if (sceneObject.OwnerID == UUID.Zero)
2912 {
2913 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2914 return false;
2915 }
2784 AddRestoredSceneObject(sceneObject, true, false); 2916 AddRestoredSceneObject(sceneObject, true, false);
2785 } 2917 }
2786 2918
@@ -2797,6 +2929,24 @@ namespace OpenSim.Region.Framework.Scenes
2797 return 2; // StateSource.PrimCrossing 2929 return 2; // StateSource.PrimCrossing
2798 } 2930 }
2799 2931
2932 public int GetUserFlags(UUID user)
2933 {
2934 //Unfortunately the SP approach means that the value is cached until region is restarted
2935 /*
2936 ScenePresence sp;
2937 if (TryGetScenePresence(user, out sp))
2938 {
2939 return sp.UserFlags;
2940 }
2941 else
2942 {
2943 */
2944 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2945 if (uac == null)
2946 return 0;
2947 return uac.UserFlags;
2948 //}
2949 }
2800 #endregion 2950 #endregion
2801 2951
2802 #region Add/Remove Avatar Methods 2952 #region Add/Remove Avatar Methods
@@ -2830,7 +2980,7 @@ namespace OpenSim.Region.Framework.Scenes
2830 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2980 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2831 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2981 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2832 2982
2833 // CheckHeartbeat(); 2983 CheckHeartbeat();
2834 2984
2835 sp = GetScenePresence(client.AgentId); 2985 sp = GetScenePresence(client.AgentId);
2836 2986
@@ -2848,6 +2998,13 @@ namespace OpenSim.Region.Framework.Scenes
2848 SubscribeToClientEvents(client); 2998 SubscribeToClientEvents(client);
2849 2999
2850 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 3000 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
3001 InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
3002 if (cof == null)
3003 sp.COF = UUID.Zero;
3004 else
3005 sp.COF = cof.ID;
3006
3007 m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
2851 m_eventManager.TriggerOnNewPresence(sp); 3008 m_eventManager.TriggerOnNewPresence(sp);
2852 3009
2853 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 3010 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
@@ -2965,19 +3122,15 @@ namespace OpenSim.Region.Framework.Scenes
2965 // and the scene presence and the client, if they exist 3122 // and the scene presence and the client, if they exist
2966 try 3123 try
2967 { 3124 {
2968 // We need to wait for the client to make UDP contact first. 3125 ScenePresence sp = GetScenePresence(agentID);
2969 // It's the UDP contact that creates the scene presence 3126
2970 ScenePresence sp = WaitGetScenePresence(agentID);
2971 if (sp != null) 3127 if (sp != null)
2972 { 3128 {
2973 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3129 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2974 3130
2975 IncomingCloseAgent(sp.UUID, false); 3131 IncomingCloseAgent(sp.UUID, false);
2976 } 3132 }
2977 else 3133
2978 {
2979 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2980 }
2981 // BANG! SLASH! 3134 // BANG! SLASH!
2982 m_authenticateHandler.RemoveCircuit(agentID); 3135 m_authenticateHandler.RemoveCircuit(agentID);
2983 3136
@@ -3022,6 +3175,8 @@ namespace OpenSim.Region.Framework.Scenes
3022 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3175 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
3023 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3176 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
3024 3177
3178 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3179
3025 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3180 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
3026 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3181 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
3027 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3182 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -3078,6 +3233,7 @@ namespace OpenSim.Region.Framework.Scenes
3078 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3233 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
3079 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3234 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
3080 client.OnCopyInventoryItem += CopyInventoryItem; 3235 client.OnCopyInventoryItem += CopyInventoryItem;
3236 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
3081 client.OnMoveInventoryItem += MoveInventoryItem; 3237 client.OnMoveInventoryItem += MoveInventoryItem;
3082 client.OnRemoveInventoryItem += RemoveInventoryItem; 3238 client.OnRemoveInventoryItem += RemoveInventoryItem;
3083 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3239 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3147,6 +3303,8 @@ namespace OpenSim.Region.Framework.Scenes
3147 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3303 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3148 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3304 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3149 3305
3306 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3307
3150 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3308 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3151 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3309 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3152 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3310 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3458,7 +3616,7 @@ namespace OpenSim.Region.Framework.Scenes
3458 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3616 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3459 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3617 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3460 if (closeChildAgents && CapsModule != null) 3618 if (closeChildAgents && CapsModule != null)
3461 CapsModule.RemoveCaps(agentID); 3619 CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode);
3462 3620
3463 if (closeChildAgents && !isChildAgent) 3621 if (closeChildAgents && !isChildAgent)
3464 { 3622 {
@@ -3491,6 +3649,7 @@ namespace OpenSim.Region.Framework.Scenes
3491 // It's possible for child agents to have transactions if changes are being made cross-border. 3649 // It's possible for child agents to have transactions if changes are being made cross-border.
3492 if (AgentTransactionsModule != null) 3650 if (AgentTransactionsModule != null)
3493 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3651 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3652 m_log.Debug("[Scene] The avatar has left the building");
3494 } 3653 }
3495 catch (Exception e) 3654 catch (Exception e)
3496 { 3655 {
@@ -3784,13 +3943,16 @@ namespace OpenSim.Region.Framework.Scenes
3784 // On login test land permisions 3943 // On login test land permisions
3785 if (vialogin) 3944 if (vialogin)
3786 { 3945 {
3946 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3947 if (cache != null)
3948 cache.Remove(acd.firstname + " " + acd.lastname);
3787 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) 3949 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y))
3788 { 3950 {
3789 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 3951 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3790 return false; 3952 return false;
3791 } 3953 }
3792 } 3954 }
3793 3955
3794 if (sp == null) // We don't have an [child] agent here already 3956 if (sp == null) // We don't have an [child] agent here already
3795 { 3957 {
3796 if (requirePresenceLookup) 3958 if (requirePresenceLookup)
@@ -3812,7 +3974,7 @@ namespace OpenSim.Region.Framework.Scenes
3812 return false; 3974 return false;
3813 } 3975 }
3814 } 3976 }
3815 3977
3816 try 3978 try
3817 { 3979 {
3818 if (!AuthorizeUser(acd, SeeIntoRegion, out reason)) 3980 if (!AuthorizeUser(acd, SeeIntoRegion, out reason))
@@ -3829,7 +3991,7 @@ namespace OpenSim.Region.Framework.Scenes
3829 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 3991 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3830 return false; 3992 return false;
3831 } 3993 }
3832 3994
3833 m_log.InfoFormat( 3995 m_log.InfoFormat(
3834 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 3996 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3835 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, 3997 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname,
@@ -3838,7 +4000,7 @@ namespace OpenSim.Region.Framework.Scenes
3838 if (CapsModule != null) 4000 if (CapsModule != null)
3839 { 4001 {
3840 CapsModule.SetAgentCapsSeeds(acd); 4002 CapsModule.SetAgentCapsSeeds(acd);
3841 CapsModule.CreateCaps(acd.AgentID); 4003 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3842 } 4004 }
3843 } 4005 }
3844 else 4006 else
@@ -3846,7 +4008,7 @@ namespace OpenSim.Region.Framework.Scenes
3846 // Let the SP know how we got here. This has a lot of interesting 4008 // Let the SP know how we got here. This has a lot of interesting
3847 // uses down the line. 4009 // uses down the line.
3848 sp.TeleportFlags = (TPFlags)teleportFlags; 4010 sp.TeleportFlags = (TPFlags)teleportFlags;
3849 4011
3850 if (sp.IsChildAgent) 4012 if (sp.IsChildAgent)
3851 { 4013 {
3852 m_log.DebugFormat( 4014 m_log.DebugFormat(
@@ -3858,7 +4020,7 @@ namespace OpenSim.Region.Framework.Scenes
3858 if (CapsModule != null) 4020 if (CapsModule != null)
3859 { 4021 {
3860 CapsModule.SetAgentCapsSeeds(acd); 4022 CapsModule.SetAgentCapsSeeds(acd);
3861 CapsModule.CreateCaps(acd.AgentID); 4023 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3862 } 4024 }
3863 } 4025 }
3864 } 4026 }
@@ -3869,6 +4031,11 @@ namespace OpenSim.Region.Framework.Scenes
3869 CacheUserName(null, acd); 4031 CacheUserName(null, acd);
3870 } 4032 }
3871 4033
4034 if (CapsModule != null)
4035 {
4036 CapsModule.ActivateCaps(acd.circuitcode);
4037 }
4038
3872 if (vialogin) 4039 if (vialogin)
3873 { 4040 {
3874// CleanDroppedAttachments(); 4041// CleanDroppedAttachments();
@@ -3960,6 +4127,8 @@ namespace OpenSim.Region.Framework.Scenes
3960 } 4127 }
3961 4128
3962 // Honor parcel landing type and position. 4129 // Honor parcel landing type and position.
4130 /*
4131 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3963 if (land != null) 4132 if (land != null)
3964 { 4133 {
3965 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 4134 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3967,6 +4136,7 @@ namespace OpenSim.Region.Framework.Scenes
3967 acd.startpos = land.LandData.UserLocation; 4136 acd.startpos = land.LandData.UserLocation;
3968 } 4137 }
3969 } 4138 }
4139 */// This is now handled properly in ScenePresence.MakeRootAgent
3970 } 4140 }
3971 4141
3972 return true; 4142 return true;
@@ -4064,7 +4234,7 @@ namespace OpenSim.Region.Framework.Scenes
4064 4234
4065 if (!m_strictAccessControl) return true; 4235 if (!m_strictAccessControl) return true;
4066 if (Permissions.IsGod(agent.AgentID)) return true; 4236 if (Permissions.IsGod(agent.AgentID)) return true;
4067 4237
4068 if (AuthorizationService != null) 4238 if (AuthorizationService != null)
4069 { 4239 {
4070 if (!AuthorizationService.IsAuthorizedForRegion( 4240 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -4085,7 +4255,8 @@ namespace OpenSim.Region.Framework.Scenes
4085 { 4255 {
4086 if (RegionInfo.EstateSettings != null) 4256 if (RegionInfo.EstateSettings != null)
4087 { 4257 {
4088 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4258 int flags = GetUserFlags(agent.AgentID);
4259 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, flags))
4089 { 4260 {
4090 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4261 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
4091 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4262 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4274,6 +4445,15 @@ namespace OpenSim.Region.Framework.Scenes
4274 m_log.DebugFormat( 4445 m_log.DebugFormat(
4275 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 4446 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
4276 4447
4448 // We have to wait until the viewer contacts this region after receiving EAC.
4449 // That calls AddNewClient, which finally creates the ScenePresence
4450 int flags = GetUserFlags(cAgentData.AgentID);
4451 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4452 {
4453 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4454 return false;
4455 }
4456
4277 // TODO: This check should probably be in QueryAccess(). 4457 // TODO: This check should probably be in QueryAccess().
4278 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4458 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4279 if (nearestParcel == null) 4459 if (nearestParcel == null)
@@ -4369,7 +4549,7 @@ namespace OpenSim.Region.Framework.Scenes
4369 /// <param name='agentID'></param> 4549 /// <param name='agentID'></param>
4370 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4550 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4371 { 4551 {
4372 int ntimes = 20; 4552 int ntimes = 30;
4373 ScenePresence sp = null; 4553 ScenePresence sp = null;
4374 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4554 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4375 Thread.Sleep(1000); 4555 Thread.Sleep(1000);
@@ -4414,6 +4594,16 @@ namespace OpenSim.Region.Framework.Scenes
4414 return false; 4594 return false;
4415 } 4595 }
4416 4596
4597 public bool IncomingCloseAgent(UUID agentID)
4598 {
4599 return IncomingCloseAgent(agentID, false);
4600 }
4601
4602 public bool IncomingCloseChildAgent(UUID agentID)
4603 {
4604 return IncomingCloseAgent(agentID, true);
4605 }
4606
4417 /// <summary> 4607 /// <summary>
4418 /// Tell a single agent to disconnect from the region. 4608 /// Tell a single agent to disconnect from the region.
4419 /// </summary> 4609 /// </summary>
@@ -4468,7 +4658,7 @@ namespace OpenSim.Region.Framework.Scenes
4468 4658
4469 if (sp != null) 4659 if (sp != null)
4470 { 4660 {
4471 sp.ControllingClient.Close(force); 4661 sp.ControllingClient.Close(force, force);
4472 return true; 4662 return true;
4473 } 4663 }
4474 4664
@@ -5086,7 +5276,7 @@ namespace OpenSim.Region.Framework.Scenes
5086 { 5276 {
5087 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 5277 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
5088 { 5278 {
5089 if (grp.RootPart.Expires <= DateTime.Now) 5279 if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now)
5090 DeleteSceneObject(grp, false); 5280 DeleteSceneObject(grp, false);
5091 } 5281 }
5092 } 5282 }
@@ -5100,35 +5290,81 @@ namespace OpenSim.Region.Framework.Scenes
5100 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5290 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
5101 } 5291 }
5102 5292
5103 public int GetHealth() 5293 public int GetHealth(out int flags, out string message)
5104 { 5294 {
5105 // Returns: 5295 // Returns:
5106 // 1 = sim is up and accepting http requests. The heartbeat has 5296 // 1 = sim is up and accepting http requests. The heartbeat has
5107 // stopped and the sim is probably locked up, but a remote 5297 // stopped and the sim is probably locked up, but a remote
5108 // admin restart may succeed 5298 // admin restart may succeed
5109 // 5299 //
5110 // 2 = Sim is up and the heartbeat is running. The sim is likely 5300 // 2 = Sim is up and the heartbeat is running. The sim is likely
5111 // usable for people within and logins _may_ work 5301 // usable for people within
5112 // 5302 //
5113 // 3 = We have seen a new user enter within the past 4 minutes 5303 // 3 = Sim is up and one packet thread is running. Sim is
5304 // unstable and will not accept new logins
5305 //
5306 // 4 = Sim is up and both packet threads are running. Sim is
5307 // likely usable
5308 //
5309 // 5 = We have seen a new user enter within the past 4 minutes
5114 // which can be seen as positive confirmation of sim health 5310 // which can be seen as positive confirmation of sim health
5115 // 5311 //
5312
5313 flags = 0;
5314 message = String.Empty;
5315
5316 CheckHeartbeat();
5317
5318 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5319 {
5320 // We're still starting
5321 // 0 means "in startup", it can't happen another way, since
5322 // to get here, we must be able to accept http connections
5323 return 0;
5324 }
5325
5116 int health=1; // Start at 1, means we're up 5326 int health=1; // Start at 1, means we're up
5117 5327
5118 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5328 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
5119 health += 1; 5329 {
5330 health+=1;
5331 flags |= 1;
5332 }
5333
5334 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5335 {
5336 health+=1;
5337 flags |= 2;
5338 }
5339
5340 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5341 {
5342 health+=1;
5343 flags |= 4;
5344 }
5120 else 5345 else
5346 {
5347int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5348System.Diagnostics.Process proc = new System.Diagnostics.Process();
5349proc.EnableRaisingEvents=false;
5350proc.StartInfo.FileName = "/bin/kill";
5351proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5352proc.Start();
5353proc.WaitForExit();
5354Thread.Sleep(1000);
5355Environment.Exit(1);
5356 }
5357
5358 if (flags != 7)
5121 return health; 5359 return health;
5122 5360
5123 // A login in the last 4 mins? We can't be doing too badly 5361 // A login in the last 4 mins? We can't be doing too badly
5124 // 5362 //
5125 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5363 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
5126 health++; 5364 health++;
5127 else 5365 else
5128 return health; 5366 return health;
5129 5367
5130// CheckHeartbeat();
5131
5132 return health; 5368 return health;
5133 } 5369 }
5134 5370
@@ -5216,7 +5452,7 @@ namespace OpenSim.Region.Framework.Scenes
5216 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5452 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5217 if (wasUsingPhysics) 5453 if (wasUsingPhysics)
5218 { 5454 {
5219 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 5455 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
5220 } 5456 }
5221 } 5457 }
5222 5458
@@ -5315,14 +5551,14 @@ namespace OpenSim.Region.Framework.Scenes
5315 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5551 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5316 } 5552 }
5317 5553
5318// private void CheckHeartbeat() 5554 private void CheckHeartbeat()
5319// { 5555 {
5320// if (m_firstHeartbeat) 5556 if (m_firstHeartbeat)
5321// return; 5557 return;
5322// 5558
5323// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5559 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5324// StartTimer(); 5560 Start();
5325// } 5561 }
5326 5562
5327 public override ISceneObject DeserializeObject(string representation) 5563 public override ISceneObject DeserializeObject(string representation)
5328 { 5564 {
@@ -5380,7 +5616,7 @@ namespace OpenSim.Region.Framework.Scenes
5380 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); 5616 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
5381 5617
5382 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); 5618 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
5383 5619
5384 return nearestRegionEdgePoint; 5620 return nearestRegionEdgePoint;
5385 } 5621 }
5386 5622
@@ -5634,7 +5870,55 @@ namespace OpenSim.Region.Framework.Scenes
5634 mapModule.GenerateMaptile(); 5870 mapModule.GenerateMaptile();
5635 } 5871 }
5636 5872
5637 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5873// public void CleanDroppedAttachments()
5874// {
5875// List<SceneObjectGroup> objectsToDelete =
5876// new List<SceneObjectGroup>();
5877//
5878// lock (m_cleaningAttachments)
5879// {
5880// ForEachSOG(delegate (SceneObjectGroup grp)
5881// {
5882// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5883// {
5884// UUID agentID = grp.OwnerID;
5885// if (agentID == UUID.Zero)
5886// {
5887// objectsToDelete.Add(grp);
5888// return;
5889// }
5890//
5891// ScenePresence sp = GetScenePresence(agentID);
5892// if (sp == null)
5893// {
5894// objectsToDelete.Add(grp);
5895// return;
5896// }
5897// }
5898// });
5899// }
5900//
5901// foreach (SceneObjectGroup grp in objectsToDelete)
5902// {
5903// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5904// DeleteSceneObject(grp, true);
5905// }
5906// }
5907
5908 public void ThreadAlive(int threadCode)
5909 {
5910 switch(threadCode)
5911 {
5912 case 1: // Incoming
5913 m_lastIncoming = Util.EnvironmentTickCount();
5914 break;
5915 case 2: // Incoming
5916 m_lastOutgoing = Util.EnvironmentTickCount();
5917 break;
5918 }
5919 }
5920
5921 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5638 { 5922 {
5639 RegenerateMaptile(); 5923 RegenerateMaptile();
5640 5924
@@ -5785,7 +6069,19 @@ namespace OpenSim.Region.Framework.Scenes
5785 return true; 6069 return true;
5786 } 6070 }
5787 6071
5788 /// <summary> 6072 public void StartTimerWatchdog()
6073 {
6074 m_timerWatchdog.Interval = 1000;
6075 m_timerWatchdog.Elapsed += TimerWatchdog;
6076 m_timerWatchdog.AutoReset = true;
6077 m_timerWatchdog.Start();
6078 }
6079
6080 public void TimerWatchdog(object sender, ElapsedEventArgs e)
6081 {
6082 CheckHeartbeat();
6083 }
6084
5789 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 6085 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5790 /// autopilot that moves an avatar to a sit target!. 6086 /// autopilot that moves an avatar to a sit target!.
5791 /// </summary> 6087 /// </summary>
@@ -5864,6 +6160,11 @@ namespace OpenSim.Region.Framework.Scenes
5864 return m_SpawnPoint - 1; 6160 return m_SpawnPoint - 1;
5865 } 6161 }
5866 6162
6163 private void HandleGcCollect(string module, string[] args)
6164 {
6165 GC.Collect();
6166 }
6167
5867 /// <summary> 6168 /// <summary>
5868 /// Wrappers to get physics modules retrieve assets. 6169 /// Wrappers to get physics modules retrieve assets.
5869 /// </summary> 6170 /// </summary>