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.cs515
1 files changed, 408 insertions, 107 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e00206f..18e7eb8 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 {
@@ -3798,13 +3957,16 @@ namespace OpenSim.Region.Framework.Scenes
3798 // On login test land permisions 3957 // On login test land permisions
3799 if (vialogin) 3958 if (vialogin)
3800 { 3959 {
3960 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3961 if (cache != null)
3962 cache.Remove(acd.firstname + " " + acd.lastname);
3801 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) 3963 if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y))
3802 { 3964 {
3803 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 3965 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3804 return false; 3966 return false;
3805 } 3967 }
3806 } 3968 }
3807 3969
3808 if (sp == null) // We don't have an [child] agent here already 3970 if (sp == null) // We don't have an [child] agent here already
3809 { 3971 {
3810 if (requirePresenceLookup) 3972 if (requirePresenceLookup)
@@ -3826,7 +3988,7 @@ namespace OpenSim.Region.Framework.Scenes
3826 return false; 3988 return false;
3827 } 3989 }
3828 } 3990 }
3829 3991
3830 try 3992 try
3831 { 3993 {
3832 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) 3994 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason))
@@ -3843,7 +4005,7 @@ namespace OpenSim.Region.Framework.Scenes
3843 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 4005 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3844 return false; 4006 return false;
3845 } 4007 }
3846 4008
3847 m_log.InfoFormat( 4009 m_log.InfoFormat(
3848 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 4010 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3849 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, 4011 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname,
@@ -3852,7 +4014,7 @@ namespace OpenSim.Region.Framework.Scenes
3852 if (CapsModule != null) 4014 if (CapsModule != null)
3853 { 4015 {
3854 CapsModule.SetAgentCapsSeeds(acd); 4016 CapsModule.SetAgentCapsSeeds(acd);
3855 CapsModule.CreateCaps(acd.AgentID); 4017 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3856 } 4018 }
3857 } 4019 }
3858 else 4020 else
@@ -3885,7 +4047,7 @@ namespace OpenSim.Region.Framework.Scenes
3885 if (CapsModule != null) 4047 if (CapsModule != null)
3886 { 4048 {
3887 CapsModule.SetAgentCapsSeeds(acd); 4049 CapsModule.SetAgentCapsSeeds(acd);
3888 CapsModule.CreateCaps(acd.AgentID); 4050 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
3889 } 4051 }
3890 } 4052 }
3891 } 4053 }
@@ -3896,6 +4058,11 @@ namespace OpenSim.Region.Framework.Scenes
3896 CacheUserName(null, acd); 4058 CacheUserName(null, acd);
3897 } 4059 }
3898 4060
4061 if (CapsModule != null)
4062 {
4063 CapsModule.ActivateCaps(acd.circuitcode);
4064 }
4065
3899 if (vialogin) 4066 if (vialogin)
3900 { 4067 {
3901// CleanDroppedAttachments(); 4068// CleanDroppedAttachments();
@@ -3987,6 +4154,8 @@ namespace OpenSim.Region.Framework.Scenes
3987 } 4154 }
3988 4155
3989 // Honor parcel landing type and position. 4156 // Honor parcel landing type and position.
4157 /*
4158 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3990 if (land != null) 4159 if (land != null)
3991 { 4160 {
3992 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 4161 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3994,6 +4163,7 @@ namespace OpenSim.Region.Framework.Scenes
3994 acd.startpos = land.LandData.UserLocation; 4163 acd.startpos = land.LandData.UserLocation;
3995 } 4164 }
3996 } 4165 }
4166 */// This is now handled properly in ScenePresence.MakeRootAgent
3997 } 4167 }
3998 4168
3999 return true; 4169 return true;
@@ -4091,7 +4261,7 @@ namespace OpenSim.Region.Framework.Scenes
4091 4261
4092 if (!m_strictAccessControl) return true; 4262 if (!m_strictAccessControl) return true;
4093 if (Permissions.IsGod(agent.AgentID)) return true; 4263 if (Permissions.IsGod(agent.AgentID)) return true;
4094 4264
4095 if (AuthorizationService != null) 4265 if (AuthorizationService != null)
4096 { 4266 {
4097 if (!AuthorizationService.IsAuthorizedForRegion( 4267 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -4112,7 +4282,8 @@ namespace OpenSim.Region.Framework.Scenes
4112 { 4282 {
4113 if (RegionInfo.EstateSettings != null) 4283 if (RegionInfo.EstateSettings != null)
4114 { 4284 {
4115 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4285 int flags = GetUserFlags(agent.AgentID);
4286 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, flags))
4116 { 4287 {
4117 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4288 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
4118 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4289 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4301,6 +4472,15 @@ namespace OpenSim.Region.Framework.Scenes
4301 m_log.DebugFormat( 4472 m_log.DebugFormat(
4302 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 4473 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
4303 4474
4475 // We have to wait until the viewer contacts this region after receiving EAC.
4476 // That calls AddNewClient, which finally creates the ScenePresence
4477 int flags = GetUserFlags(cAgentData.AgentID);
4478 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4479 {
4480 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4481 return false;
4482 }
4483
4304 // TODO: This check should probably be in QueryAccess(). 4484 // TODO: This check should probably be in QueryAccess().
4305 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4485 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4306 if (nearestParcel == null) 4486 if (nearestParcel == null)
@@ -4396,7 +4576,7 @@ namespace OpenSim.Region.Framework.Scenes
4396 /// <param name='agentID'></param> 4576 /// <param name='agentID'></param>
4397 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4577 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4398 { 4578 {
4399 int ntimes = 20; 4579 int ntimes = 30;
4400 ScenePresence sp = null; 4580 ScenePresence sp = null;
4401 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4581 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4402 Thread.Sleep(1000); 4582 Thread.Sleep(1000);
@@ -4458,6 +4638,16 @@ namespace OpenSim.Region.Framework.Scenes
4458 return false; 4638 return false;
4459 } 4639 }
4460 4640
4641 public bool IncomingCloseAgent(UUID agentID)
4642 {
4643 return IncomingCloseAgent(agentID, false);
4644 }
4645
4646 public bool IncomingCloseChildAgent(UUID agentID)
4647 {
4648 return IncomingCloseAgent(agentID, true);
4649 }
4650
4461 /// <summary> 4651 /// <summary>
4462 /// Tell a single agent to prepare to close. 4652 /// Tell a single agent to prepare to close.
4463 /// </summary> 4653 /// </summary>
@@ -4556,7 +4746,7 @@ namespace OpenSim.Region.Framework.Scenes
4556 4746
4557 if (sp != null) 4747 if (sp != null)
4558 { 4748 {
4559 sp.ControllingClient.Close(force); 4749 sp.ControllingClient.Close(force, force);
4560 return true; 4750 return true;
4561 } 4751 }
4562 4752
@@ -5174,7 +5364,7 @@ namespace OpenSim.Region.Framework.Scenes
5174 { 5364 {
5175 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 5365 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
5176 { 5366 {
5177 if (grp.RootPart.Expires <= DateTime.Now) 5367 if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now)
5178 DeleteSceneObject(grp, false); 5368 DeleteSceneObject(grp, false);
5179 } 5369 }
5180 } 5370 }
@@ -5188,35 +5378,81 @@ namespace OpenSim.Region.Framework.Scenes
5188 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5378 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
5189 } 5379 }
5190 5380
5191 public int GetHealth() 5381 public int GetHealth(out int flags, out string message)
5192 { 5382 {
5193 // Returns: 5383 // Returns:
5194 // 1 = sim is up and accepting http requests. The heartbeat has 5384 // 1 = sim is up and accepting http requests. The heartbeat has
5195 // stopped and the sim is probably locked up, but a remote 5385 // stopped and the sim is probably locked up, but a remote
5196 // admin restart may succeed 5386 // admin restart may succeed
5197 // 5387 //
5198 // 2 = Sim is up and the heartbeat is running. The sim is likely 5388 // 2 = Sim is up and the heartbeat is running. The sim is likely
5199 // usable for people within and logins _may_ work 5389 // usable for people within
5390 //
5391 // 3 = Sim is up and one packet thread is running. Sim is
5392 // unstable and will not accept new logins
5200 // 5393 //
5201 // 3 = We have seen a new user enter within the past 4 minutes 5394 // 4 = Sim is up and both packet threads are running. Sim is
5395 // likely usable
5396 //
5397 // 5 = We have seen a new user enter within the past 4 minutes
5202 // which can be seen as positive confirmation of sim health 5398 // which can be seen as positive confirmation of sim health
5203 // 5399 //
5400
5401 flags = 0;
5402 message = String.Empty;
5403
5404 CheckHeartbeat();
5405
5406 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5407 {
5408 // We're still starting
5409 // 0 means "in startup", it can't happen another way, since
5410 // to get here, we must be able to accept http connections
5411 return 0;
5412 }
5413
5204 int health=1; // Start at 1, means we're up 5414 int health=1; // Start at 1, means we're up
5205 5415
5206 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5416 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
5207 health += 1; 5417 {
5418 health+=1;
5419 flags |= 1;
5420 }
5421
5422 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5423 {
5424 health+=1;
5425 flags |= 2;
5426 }
5427
5428 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5429 {
5430 health+=1;
5431 flags |= 4;
5432 }
5208 else 5433 else
5434 {
5435int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5436System.Diagnostics.Process proc = new System.Diagnostics.Process();
5437proc.EnableRaisingEvents=false;
5438proc.StartInfo.FileName = "/bin/kill";
5439proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5440proc.Start();
5441proc.WaitForExit();
5442Thread.Sleep(1000);
5443Environment.Exit(1);
5444 }
5445
5446 if (flags != 7)
5209 return health; 5447 return health;
5210 5448
5211 // A login in the last 4 mins? We can't be doing too badly 5449 // A login in the last 4 mins? We can't be doing too badly
5212 // 5450 //
5213 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5451 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
5214 health++; 5452 health++;
5215 else 5453 else
5216 return health; 5454 return health;
5217 5455
5218// CheckHeartbeat();
5219
5220 return health; 5456 return health;
5221 } 5457 }
5222 5458
@@ -5304,7 +5540,7 @@ namespace OpenSim.Region.Framework.Scenes
5304 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5540 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5305 if (wasUsingPhysics) 5541 if (wasUsingPhysics)
5306 { 5542 {
5307 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 5543 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
5308 } 5544 }
5309 } 5545 }
5310 5546
@@ -5403,14 +5639,14 @@ namespace OpenSim.Region.Framework.Scenes
5403 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5639 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5404 } 5640 }
5405 5641
5406// private void CheckHeartbeat() 5642 private void CheckHeartbeat()
5407// { 5643 {
5408// if (m_firstHeartbeat) 5644 if (m_firstHeartbeat)
5409// return; 5645 return;
5410// 5646
5411// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5647 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5412// StartTimer(); 5648 Start();
5413// } 5649 }
5414 5650
5415 public override ISceneObject DeserializeObject(string representation) 5651 public override ISceneObject DeserializeObject(string representation)
5416 { 5652 {
@@ -5468,7 +5704,7 @@ namespace OpenSim.Region.Framework.Scenes
5468 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); 5704 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
5469 5705
5470 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); 5706 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
5471 5707
5472 return nearestRegionEdgePoint; 5708 return nearestRegionEdgePoint;
5473 } 5709 }
5474 5710
@@ -5722,7 +5958,55 @@ namespace OpenSim.Region.Framework.Scenes
5722 mapModule.GenerateMaptile(); 5958 mapModule.GenerateMaptile();
5723 } 5959 }
5724 5960
5725 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5961// public void CleanDroppedAttachments()
5962// {
5963// List<SceneObjectGroup> objectsToDelete =
5964// new List<SceneObjectGroup>();
5965//
5966// lock (m_cleaningAttachments)
5967// {
5968// ForEachSOG(delegate (SceneObjectGroup grp)
5969// {
5970// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5971// {
5972// UUID agentID = grp.OwnerID;
5973// if (agentID == UUID.Zero)
5974// {
5975// objectsToDelete.Add(grp);
5976// return;
5977// }
5978//
5979// ScenePresence sp = GetScenePresence(agentID);
5980// if (sp == null)
5981// {
5982// objectsToDelete.Add(grp);
5983// return;
5984// }
5985// }
5986// });
5987// }
5988//
5989// foreach (SceneObjectGroup grp in objectsToDelete)
5990// {
5991// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5992// DeleteSceneObject(grp, true);
5993// }
5994// }
5995
5996 public void ThreadAlive(int threadCode)
5997 {
5998 switch(threadCode)
5999 {
6000 case 1: // Incoming
6001 m_lastIncoming = Util.EnvironmentTickCount();
6002 break;
6003 case 2: // Incoming
6004 m_lastOutgoing = Util.EnvironmentTickCount();
6005 break;
6006 }
6007 }
6008
6009 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5726 { 6010 {
5727 RegenerateMaptile(); 6011 RegenerateMaptile();
5728 6012
@@ -5873,7 +6157,19 @@ namespace OpenSim.Region.Framework.Scenes
5873 return true; 6157 return true;
5874 } 6158 }
5875 6159
5876 /// <summary> 6160 public void StartTimerWatchdog()
6161 {
6162 m_timerWatchdog.Interval = 1000;
6163 m_timerWatchdog.Elapsed += TimerWatchdog;
6164 m_timerWatchdog.AutoReset = true;
6165 m_timerWatchdog.Start();
6166 }
6167
6168 public void TimerWatchdog(object sender, ElapsedEventArgs e)
6169 {
6170 CheckHeartbeat();
6171 }
6172
5877 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 6173 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5878 /// autopilot that moves an avatar to a sit target!. 6174 /// autopilot that moves an avatar to a sit target!.
5879 /// </summary> 6175 /// </summary>
@@ -5952,6 +6248,11 @@ namespace OpenSim.Region.Framework.Scenes
5952 return m_SpawnPoint - 1; 6248 return m_SpawnPoint - 1;
5953 } 6249 }
5954 6250
6251 private void HandleGcCollect(string module, string[] args)
6252 {
6253 GC.Collect();
6254 }
6255
5955 /// <summary> 6256 /// <summary>
5956 /// Wrappers to get physics modules retrieve assets. 6257 /// Wrappers to get physics modules retrieve assets.
5957 /// </summary> 6258 /// </summary>