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.cs784
1 files changed, 590 insertions, 194 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 40cfb72..a8594e4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -128,6 +128,7 @@ namespace OpenSim.Region.Framework.Scenes
128 // TODO: need to figure out how allow client agents but deny 128 // TODO: need to figure out how allow client agents but deny
129 // root agents when ACL denies access to root agent 129 // root agents when ACL denies access to root agent
130 public bool m_strictAccessControl = true; 130 public bool m_strictAccessControl = true;
131 public bool m_seeIntoBannedRegion = false;
131 public int MaxUndoCount = 5; 132 public int MaxUndoCount = 5;
132 133
133 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 134 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
@@ -144,12 +145,14 @@ namespace OpenSim.Region.Framework.Scenes
144 145
145 protected int m_splitRegionID; 146 protected int m_splitRegionID;
146 protected Timer m_restartWaitTimer = new Timer(); 147 protected Timer m_restartWaitTimer = new Timer();
148 protected Timer m_timerWatchdog = new Timer();
147 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 149 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
148 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 150 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
149 protected string m_simulatorVersion = "OpenSimulator Server"; 151 protected string m_simulatorVersion = "OpenSimulator Server";
150 protected ModuleLoader m_moduleLoader; 152 protected ModuleLoader m_moduleLoader;
151 protected AgentCircuitManager m_authenticateHandler; 153 protected AgentCircuitManager m_authenticateHandler;
152 protected SceneCommunicationService m_sceneGridService; 154 protected SceneCommunicationService m_sceneGridService;
155 protected ISnmpModule m_snmpService = null;
153 156
154 protected ISimulationDataService m_SimulationDataService; 157 protected ISimulationDataService m_SimulationDataService;
155 protected IEstateDataService m_EstateDataService; 158 protected IEstateDataService m_EstateDataService;
@@ -211,7 +214,7 @@ namespace OpenSim.Region.Framework.Scenes
211 private int m_update_events = 1; 214 private int m_update_events = 1;
212 private int m_update_backup = 200; 215 private int m_update_backup = 200;
213 private int m_update_terrain = 50; 216 private int m_update_terrain = 50;
214// private int m_update_land = 1; 217 private int m_update_land = 10;
215 private int m_update_coarse_locations = 50; 218 private int m_update_coarse_locations = 50;
216 219
217 private int agentMS; 220 private int agentMS;
@@ -224,13 +227,13 @@ namespace OpenSim.Region.Framework.Scenes
224 private int backupMS; 227 private int backupMS;
225 private int terrainMS; 228 private int terrainMS;
226 private int landMS; 229 private int landMS;
227 private int spareMS;
228 230
229 /// <summary> 231 /// <summary>
230 /// Tick at which the last frame was processed. 232 /// Tick at which the last frame was processed.
231 /// </summary> 233 /// </summary>
232 private int m_lastFrameTick; 234 private int m_lastFrameTick;
233 235
236 public bool CombineRegions = false;
234 /// <summary> 237 /// <summary>
235 /// Tick at which the last maintenance run occurred. 238 /// Tick at which the last maintenance run occurred.
236 /// </summary> 239 /// </summary>
@@ -261,6 +264,11 @@ namespace OpenSim.Region.Framework.Scenes
261 /// </summary> 264 /// </summary>
262 private int m_LastLogin; 265 private int m_LastLogin;
263 266
267 private int m_lastIncoming;
268 private int m_lastOutgoing;
269 private int m_hbRestarts = 0;
270
271
264 /// <summary> 272 /// <summary>
265 /// Thread that runs the scene loop. 273 /// Thread that runs the scene loop.
266 /// </summary> 274 /// </summary>
@@ -276,7 +284,7 @@ namespace OpenSim.Region.Framework.Scenes
276 private volatile bool m_shuttingDown; 284 private volatile bool m_shuttingDown;
277 285
278// private int m_lastUpdate; 286// private int m_lastUpdate;
279// private bool m_firstHeartbeat = true; 287 private bool m_firstHeartbeat = true;
280 288
281 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 289 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
282 private bool m_reprioritizationEnabled = true; 290 private bool m_reprioritizationEnabled = true;
@@ -321,6 +329,19 @@ namespace OpenSim.Region.Framework.Scenes
321 get { return m_sceneGridService; } 329 get { return m_sceneGridService; }
322 } 330 }
323 331
332 public ISnmpModule SnmpService
333 {
334 get
335 {
336 if (m_snmpService == null)
337 {
338 m_snmpService = RequestModuleInterface<ISnmpModule>();
339 }
340
341 return m_snmpService;
342 }
343 }
344
324 public ISimulationDataService SimulationDataService 345 public ISimulationDataService SimulationDataService
325 { 346 {
326 get 347 get
@@ -620,6 +641,8 @@ namespace OpenSim.Region.Framework.Scenes
620 m_SimulationDataService = simDataService; 641 m_SimulationDataService = simDataService;
621 m_EstateDataService = estateDataService; 642 m_EstateDataService = estateDataService;
622 m_regionHandle = RegionInfo.RegionHandle; 643 m_regionHandle = RegionInfo.RegionHandle;
644 m_lastIncoming = 0;
645 m_lastOutgoing = 0;
623 646
624 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 647 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
625 m_asyncSceneObjectDeleter.Enabled = true; 648 m_asyncSceneObjectDeleter.Enabled = true;
@@ -700,120 +723,130 @@ namespace OpenSim.Region.Framework.Scenes
700 723
701 // Region config overrides global config 724 // Region config overrides global config
702 // 725 //
703 if (m_config.Configs["Startup"] != null) 726 try
704 { 727 {
705 IConfig startupConfig = m_config.Configs["Startup"]; 728 if (m_config.Configs["Startup"] != null)
706
707 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
708
709 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
710 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
711 if (!m_useBackup)
712 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
713
714 //Animation states
715 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
716
717 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
718 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
719
720 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
721 if (RegionInfo.NonphysPrimMax > 0)
722 { 729 {
723 m_maxNonphys = RegionInfo.NonphysPrimMax; 730 IConfig startupConfig = m_config.Configs["Startup"];
724 }
725 731
726 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 732 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
727 733
728 if (RegionInfo.PhysPrimMax > 0) 734 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
729 { 735 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
730 m_maxPhys = RegionInfo.PhysPrimMax; 736 if (!m_useBackup)
731 } 737 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
738
739 //Animation states
740 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
732 741
733 // Here, if clamping is requested in either global or 742 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
734 // local config, it will be used 743 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
735 //
736 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
737 if (RegionInfo.ClampPrimSize)
738 {
739 m_clampPrimSize = true;
740 }
741 744
742 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 745 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
743 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 746 if (RegionInfo.NonphysPrimMax > 0)
744 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 747 {
745 m_dontPersistBefore = 748 m_maxNonphys = RegionInfo.NonphysPrimMax;
746 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); 749 }
747 m_dontPersistBefore *= 10000000;
748 m_persistAfter =
749 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
750 m_persistAfter *= 10000000;
751 750
752 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 751 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
753 752
754 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 753 if (RegionInfo.PhysPrimMax > 0)
755 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 754 {
755 m_maxPhys = RegionInfo.PhysPrimMax;
756 }
756 757
757 IConfig packetConfig = m_config.Configs["PacketPool"]; 758 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
758 if (packetConfig != null) 759 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
759 {
760 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
761 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
762 }
763 760
764 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 761 // Here, if clamping is requested in either global or
762 // local config, it will be used
763 //
764 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
765 if (RegionInfo.ClampPrimSize)
766 {
767 m_clampPrimSize = true;
768 }
765 769
766 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 770 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
767 if (m_generateMaptiles) 771 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
768 { 772 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
769 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 773 m_dontPersistBefore =
770 if (maptileRefresh != 0) 774 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
775 m_dontPersistBefore *= 10000000;
776 m_persistAfter =
777 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
778 m_persistAfter *= 10000000;
779
780 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
781 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
782
783 IConfig packetConfig = m_config.Configs["PacketPool"];
784 if (packetConfig != null)
771 { 785 {
772 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 786 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
773 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; 787 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
774 m_mapGenerationTimer.AutoReset = true;
775 m_mapGenerationTimer.Start();
776 } 788 }
777 }
778 else
779 {
780 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
781 UUID tileID;
782 789
783 if (UUID.TryParse(tile, out tileID)) 790 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
791 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
792 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
793
794 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
795 if (m_generateMaptiles)
784 { 796 {
785 RegionInfo.RegionSettings.TerrainImageID = tileID; 797 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
798 if (maptileRefresh != 0)
799 {
800 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
801 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
802 m_mapGenerationTimer.AutoReset = true;
803 m_mapGenerationTimer.Start();
804 }
786 } 805 }
787 } 806 else
807 {
808 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
809 UUID tileID;
788 810
789 string grant = startupConfig.GetString("AllowedClients", String.Empty); 811 if (UUID.TryParse(tile, out tileID))
790 if (grant.Length > 0) 812 {
791 { 813 RegionInfo.RegionSettings.TerrainImageID = tileID;
792 foreach (string viewer in grant.Split('|')) 814 }
815 }
816
817 string grant = startupConfig.GetString("AllowedClients", String.Empty);
818 if (grant.Length > 0)
793 { 819 {
794 m_AllowedViewers.Add(viewer.Trim().ToLower()); 820 foreach (string viewer in grant.Split(','))
821 {
822 m_AllowedViewers.Add(viewer.Trim().ToLower());
823 }
795 } 824 }
796 }
797 825
798 grant = startupConfig.GetString("BannedClients", String.Empty); 826 grant = startupConfig.GetString("BannedClients", String.Empty);
799 if (grant.Length > 0) 827 if (grant.Length > 0)
800 {
801 foreach (string viewer in grant.Split('|'))
802 { 828 {
803 m_BannedViewers.Add(viewer.Trim().ToLower()); 829 foreach (string viewer in grant.Split(','))
830 {
831 m_BannedViewers.Add(viewer.Trim().ToLower());
832 }
804 } 833 }
805 }
806 834
807 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 835 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
808 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 836 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
809 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 837 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
810 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 838 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
811 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 839 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
812 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); 840 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
813 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); 841 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
814 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); 842 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
815 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 843 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
816 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 844 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
845 }
846 }
847 catch (Exception e)
848 {
849 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
817 } 850 }
818 851
819 // FIXME: Ultimately this should be in a module. 852 // FIXME: Ultimately this should be in a module.
@@ -856,6 +889,8 @@ namespace OpenSim.Region.Framework.Scenes
856 StatsReporter = new SimStatsReporter(this); 889 StatsReporter = new SimStatsReporter(this);
857 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 890 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
858 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 891 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
892
893 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
859 } 894 }
860 895
861 public Scene(RegionInfo regInfo) : base(regInfo) 896 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1258,7 +1293,22 @@ namespace OpenSim.Region.Framework.Scenes
1258 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1293 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1259 if (m_heartbeatThread != null) 1294 if (m_heartbeatThread != null)
1260 { 1295 {
1296 m_hbRestarts++;
1297 if(m_hbRestarts > 10)
1298 Environment.Exit(1);
1299 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1300
1301//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1302//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1303//proc.EnableRaisingEvents=false;
1304//proc.StartInfo.FileName = "/bin/kill";
1305//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1306//proc.Start();
1307//proc.WaitForExit();
1308//Thread.Sleep(1000);
1309//Environment.Exit(1);
1261 m_heartbeatThread.Abort(); 1310 m_heartbeatThread.Abort();
1311 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1262 m_heartbeatThread = null; 1312 m_heartbeatThread = null;
1263 } 1313 }
1264// m_lastUpdate = Util.EnvironmentTickCount(); 1314// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1405,16 +1455,20 @@ namespace OpenSim.Region.Framework.Scenes
1405 endFrame = Frame + frames; 1455 endFrame = Frame + frames;
1406 1456
1407 float physicsFPS = 0f; 1457 float physicsFPS = 0f;
1408 int previousFrameTick, tmpMS; 1458 int tmpMS;
1409 int maintc = Util.EnvironmentTickCount(); 1459 int previousFrameTick;
1460 int maintc;
1461 int sleepMS;
1462 int framestart;
1410 1463
1411 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1464 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1412 { 1465 {
1466 framestart = Util.EnvironmentTickCount();
1413 ++Frame; 1467 ++Frame;
1414 1468
1415// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1469// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1416 1470
1417 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1471 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1418 1472
1419 try 1473 try
1420 { 1474 {
@@ -1466,6 +1520,7 @@ namespace OpenSim.Region.Framework.Scenes
1466 m_sceneGraph.UpdatePresences(); 1520 m_sceneGraph.UpdatePresences();
1467 1521
1468 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1522 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1523
1469 1524
1470 // Delete temp-on-rez stuff 1525 // Delete temp-on-rez stuff
1471 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1526 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1547,34 +1602,37 @@ namespace OpenSim.Region.Framework.Scenes
1547 1602
1548 Watchdog.UpdateThread(); 1603 Watchdog.UpdateThread();
1549 1604
1605 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1606
1607 StatsReporter.AddPhysicsFPS(physicsFPS);
1608 StatsReporter.AddTimeDilation(TimeDilation);
1609 StatsReporter.AddFPS(1);
1610
1611 StatsReporter.addAgentMS(agentMS);
1612 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1613 StatsReporter.addOtherMS(otherMS);
1614 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1615
1550 previousFrameTick = m_lastFrameTick; 1616 previousFrameTick = m_lastFrameTick;
1551 m_lastFrameTick = Util.EnvironmentTickCount(); 1617 m_lastFrameTick = Util.EnvironmentTickCount();
1552 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1618 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1553 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1619 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1554 1620
1621 m_firstHeartbeat = false;
1622
1623 sleepMS = Util.EnvironmentTickCount();
1624
1555 if (tmpMS > 0) 1625 if (tmpMS > 0)
1556 {
1557 Thread.Sleep(tmpMS); 1626 Thread.Sleep(tmpMS);
1558 spareMS += tmpMS;
1559 }
1560
1561 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1562 maintc = Util.EnvironmentTickCount();
1563 1627
1564 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1628 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1629 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1630 StatsReporter.addSleepMS(sleepMS);
1631 StatsReporter.addFrameMS(frameMS);
1565 1632
1566 // if (Frame%m_update_avatars == 0) 1633 // if (Frame%m_update_avatars == 0)
1567 // UpdateInWorldTime(); 1634 // UpdateInWorldTime();
1568 StatsReporter.AddPhysicsFPS(physicsFPS);
1569 StatsReporter.AddTimeDilation(TimeDilation);
1570 StatsReporter.AddFPS(1);
1571 1635
1572 StatsReporter.addFrameMS(frameMS);
1573 StatsReporter.addAgentMS(agentMS);
1574 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1575 StatsReporter.addOtherMS(otherMS);
1576 StatsReporter.AddSpareMS(spareMS);
1577 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1578 1636
1579 // Optionally warn if a frame takes double the amount of time that it should. 1637 // Optionally warn if a frame takes double the amount of time that it should.
1580 if (DebugUpdates 1638 if (DebugUpdates
@@ -1602,9 +1660,9 @@ namespace OpenSim.Region.Framework.Scenes
1602 1660
1603 private void CheckAtTargets() 1661 private void CheckAtTargets()
1604 { 1662 {
1605 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1663 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1606 lock (m_groupsWithTargets) 1664 lock (m_groupsWithTargets)
1607 objs = m_groupsWithTargets.Values; 1665 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1608 1666
1609 foreach (SceneObjectGroup entry in objs) 1667 foreach (SceneObjectGroup entry in objs)
1610 entry.checkAtTargets(); 1668 entry.checkAtTargets();
@@ -1685,7 +1743,7 @@ namespace OpenSim.Region.Framework.Scenes
1685 msg.fromAgentName = "Server"; 1743 msg.fromAgentName = "Server";
1686 msg.dialog = (byte)19; // Object msg 1744 msg.dialog = (byte)19; // Object msg
1687 msg.fromGroup = false; 1745 msg.fromGroup = false;
1688 msg.offline = (byte)0; 1746 msg.offline = (byte)1;
1689 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1747 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1690 msg.Position = Vector3.Zero; 1748 msg.Position = Vector3.Zero;
1691 msg.RegionID = RegionInfo.RegionID.Guid; 1749 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1907,6 +1965,19 @@ namespace OpenSim.Region.Framework.Scenes
1907 EventManager.TriggerPrimsLoaded(this); 1965 EventManager.TriggerPrimsLoaded(this);
1908 } 1966 }
1909 1967
1968 public bool SuportsRayCastFiltered()
1969 {
1970 if (PhysicsScene == null)
1971 return false;
1972 return PhysicsScene.SuportsRaycastWorldFiltered();
1973 }
1974
1975 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
1976 {
1977 if (PhysicsScene == null)
1978 return null;
1979 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
1980 }
1910 1981
1911 /// <summary> 1982 /// <summary>
1912 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 1983 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1923,14 +1994,24 @@ namespace OpenSim.Region.Framework.Scenes
1923 /// <returns></returns> 1994 /// <returns></returns>
1924 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1995 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1925 { 1996 {
1997
1998 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1999 Vector3 wpos = Vector3.Zero;
2000 // Check for water surface intersection from above
2001 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2002 {
2003 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2004 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2005 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2006 wpos.Z = wheight;
2007 }
2008
1926 Vector3 pos = Vector3.Zero; 2009 Vector3 pos = Vector3.Zero;
1927 if (RayEndIsIntersection == (byte)1) 2010 if (RayEndIsIntersection == (byte)1)
1928 { 2011 {
1929 pos = RayEnd; 2012 pos = RayEnd;
1930 return pos;
1931 } 2013 }
1932 2014 else if (RayTargetID != UUID.Zero)
1933 if (RayTargetID != UUID.Zero)
1934 { 2015 {
1935 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2016 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1936 2017
@@ -1952,7 +2033,7 @@ namespace OpenSim.Region.Framework.Scenes
1952 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2033 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1953 2034
1954 // Un-comment out the following line to Get Raytrace results printed to the console. 2035 // Un-comment out the following line to Get Raytrace results printed to the console.
1955 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2036 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1956 float ScaleOffset = 0.5f; 2037 float ScaleOffset = 0.5f;
1957 2038
1958 // If we hit something 2039 // If we hit something
@@ -1975,13 +2056,10 @@ namespace OpenSim.Region.Framework.Scenes
1975 //pos.Z -= 0.25F; 2056 //pos.Z -= 0.25F;
1976 2057
1977 } 2058 }
1978
1979 return pos;
1980 } 2059 }
1981 else 2060 else
1982 { 2061 {
1983 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2062 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1984
1985 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2063 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1986 2064
1987 // Un-comment the following line to print the raytrace results to the console. 2065 // Un-comment the following line to print the raytrace results to the console.
@@ -1990,13 +2068,12 @@ namespace OpenSim.Region.Framework.Scenes
1990 if (ei.HitTF) 2068 if (ei.HitTF)
1991 { 2069 {
1992 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2070 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1993 } else 2071 }
2072 else
1994 { 2073 {
1995 // fall back to our stupid functionality 2074 // fall back to our stupid functionality
1996 pos = RayEnd; 2075 pos = RayEnd;
1997 } 2076 }
1998
1999 return pos;
2000 } 2077 }
2001 } 2078 }
2002 else 2079 else
@@ -2007,8 +2084,12 @@ namespace OpenSim.Region.Framework.Scenes
2007 //increase height so its above the ground. 2084 //increase height so its above the ground.
2008 //should be getting the normal of the ground at the rez point and using that? 2085 //should be getting the normal of the ground at the rez point and using that?
2009 pos.Z += scale.Z / 2f; 2086 pos.Z += scale.Z / 2f;
2010 return pos; 2087// return pos;
2011 } 2088 }
2089
2090 // check against posible water intercept
2091 if (wpos.Z > pos.Z) pos = wpos;
2092 return pos;
2012 } 2093 }
2013 2094
2014 2095
@@ -2097,7 +2178,10 @@ namespace OpenSim.Region.Framework.Scenes
2097 public bool AddRestoredSceneObject( 2178 public bool AddRestoredSceneObject(
2098 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2179 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2099 { 2180 {
2100 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2181 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2182 if (result)
2183 sceneObject.IsDeleted = false;
2184 return result;
2101 } 2185 }
2102 2186
2103 /// <summary> 2187 /// <summary>
@@ -2189,6 +2273,15 @@ namespace OpenSim.Region.Framework.Scenes
2189 /// </summary> 2273 /// </summary>
2190 public void DeleteAllSceneObjects() 2274 public void DeleteAllSceneObjects()
2191 { 2275 {
2276 DeleteAllSceneObjects(false);
2277 }
2278
2279 /// <summary>
2280 /// Delete every object from the scene. This does not include attachments worn by avatars.
2281 /// </summary>
2282 public void DeleteAllSceneObjects(bool exceptNoCopy)
2283 {
2284 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2192 lock (Entities) 2285 lock (Entities)
2193 { 2286 {
2194 EntityBase[] entities = Entities.GetEntities(); 2287 EntityBase[] entities = Entities.GetEntities();
@@ -2197,11 +2290,24 @@ namespace OpenSim.Region.Framework.Scenes
2197 if (e is SceneObjectGroup) 2290 if (e is SceneObjectGroup)
2198 { 2291 {
2199 SceneObjectGroup sog = (SceneObjectGroup)e; 2292 SceneObjectGroup sog = (SceneObjectGroup)e;
2200 if (!sog.IsAttachment) 2293 if (sog != null && !sog.IsAttachment)
2201 DeleteSceneObject((SceneObjectGroup)e, false); 2294 {
2295 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2296 {
2297 DeleteSceneObject((SceneObjectGroup)e, false);
2298 }
2299 else
2300 {
2301 toReturn.Add((SceneObjectGroup)e);
2302 }
2303 }
2202 } 2304 }
2203 } 2305 }
2204 } 2306 }
2307 if (toReturn.Count > 0)
2308 {
2309 returnObjects(toReturn.ToArray(), UUID.Zero);
2310 }
2205 } 2311 }
2206 2312
2207 /// <summary> 2313 /// <summary>
@@ -2253,6 +2359,8 @@ namespace OpenSim.Region.Framework.Scenes
2253 } 2359 }
2254 2360
2255 group.DeleteGroupFromScene(silent); 2361 group.DeleteGroupFromScene(silent);
2362 if (!silent)
2363 SendKillObject(new List<uint>() { group.LocalId });
2256 2364
2257// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2365// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2258 } 2366 }
@@ -2543,7 +2651,7 @@ namespace OpenSim.Region.Framework.Scenes
2543 // If the user is banned, we won't let any of their objects 2651 // If the user is banned, we won't let any of their objects
2544 // enter. Period. 2652 // enter. Period.
2545 // 2653 //
2546 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2654 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2547 { 2655 {
2548 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2656 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2549 return false; 2657 return false;
@@ -2551,6 +2659,8 @@ namespace OpenSim.Region.Framework.Scenes
2551 2659
2552 if (newPosition != Vector3.Zero) 2660 if (newPosition != Vector3.Zero)
2553 newObject.RootPart.GroupPosition = newPosition; 2661 newObject.RootPart.GroupPosition = newPosition;
2662 if (newObject.RootPart.KeyframeMotion != null)
2663 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2554 2664
2555 if (!AddSceneObject(newObject)) 2665 if (!AddSceneObject(newObject))
2556 { 2666 {
@@ -2595,6 +2705,23 @@ namespace OpenSim.Region.Framework.Scenes
2595 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2705 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2596 public bool AddSceneObject(SceneObjectGroup sceneObject) 2706 public bool AddSceneObject(SceneObjectGroup sceneObject)
2597 { 2707 {
2708 if (sceneObject.OwnerID == UUID.Zero)
2709 {
2710 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2711 return false;
2712 }
2713
2714 // If the user is banned, we won't let any of their objects
2715 // enter. Period.
2716 //
2717 int flags = GetUserFlags(sceneObject.OwnerID);
2718 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2719 {
2720 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2721
2722 return false;
2723 }
2724
2598 // Force allocation of new LocalId 2725 // Force allocation of new LocalId
2599 // 2726 //
2600 SceneObjectPart[] parts = sceneObject.Parts; 2727 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2628,16 +2755,27 @@ namespace OpenSim.Region.Framework.Scenes
2628 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2755 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2629 2756
2630 if (AttachmentsModule != null) 2757 if (AttachmentsModule != null)
2631 AttachmentsModule.AttachObject(sp, grp, 0, false); 2758 AttachmentsModule.AttachObject(sp, grp, 0, false, false);
2632 } 2759 }
2633 else 2760 else
2634 { 2761 {
2762 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2635 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2763 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2636 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2764 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2637 } 2765 }
2766 if (sceneObject.OwnerID == UUID.Zero)
2767 {
2768 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2769 return false;
2770 }
2638 } 2771 }
2639 else 2772 else
2640 { 2773 {
2774 if (sceneObject.OwnerID == UUID.Zero)
2775 {
2776 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2777 return false;
2778 }
2641 AddRestoredSceneObject(sceneObject, true, false); 2779 AddRestoredSceneObject(sceneObject, true, false);
2642 } 2780 }
2643 2781
@@ -2654,6 +2792,24 @@ namespace OpenSim.Region.Framework.Scenes
2654 return 2; // StateSource.PrimCrossing 2792 return 2; // StateSource.PrimCrossing
2655 } 2793 }
2656 2794
2795 public int GetUserFlags(UUID user)
2796 {
2797 //Unfortunately the SP approach means that the value is cached until region is restarted
2798 /*
2799 ScenePresence sp;
2800 if (TryGetScenePresence(user, out sp))
2801 {
2802 return sp.UserFlags;
2803 }
2804 else
2805 {
2806 */
2807 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2808 if (uac == null)
2809 return 0;
2810 return uac.UserFlags;
2811 //}
2812 }
2657 #endregion 2813 #endregion
2658 2814
2659 #region Add/Remove Avatar Methods 2815 #region Add/Remove Avatar Methods
@@ -2667,7 +2823,7 @@ namespace OpenSim.Region.Framework.Scenes
2667 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2823 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2668 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2824 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2669 2825
2670// CheckHeartbeat(); 2826 CheckHeartbeat();
2671 2827
2672 ScenePresence sp = GetScenePresence(client.AgentId); 2828 ScenePresence sp = GetScenePresence(client.AgentId);
2673 2829
@@ -2721,7 +2877,13 @@ namespace OpenSim.Region.Framework.Scenes
2721 2877
2722 EventManager.TriggerOnNewClient(client); 2878 EventManager.TriggerOnNewClient(client);
2723 if (vialogin) 2879 if (vialogin)
2880 {
2724 EventManager.TriggerOnClientLogin(client); 2881 EventManager.TriggerOnClientLogin(client);
2882 // Send initial parcel data
2883 Vector3 pos = sp.AbsolutePosition;
2884 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2885 land.SendLandUpdateToClient(client);
2886 }
2725 2887
2726 return sp; 2888 return sp;
2727 } 2889 }
@@ -2810,19 +2972,12 @@ namespace OpenSim.Region.Framework.Scenes
2810 // and the scene presence and the client, if they exist 2972 // and the scene presence and the client, if they exist
2811 try 2973 try
2812 { 2974 {
2813 // We need to wait for the client to make UDP contact first. 2975 ScenePresence sp = GetScenePresence(agentID);
2814 // It's the UDP contact that creates the scene presence 2976 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2815 ScenePresence sp = WaitGetScenePresence(agentID); 2977
2816 if (sp != null) 2978 if (sp != null)
2817 {
2818 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2819
2820 sp.ControllingClient.Close(); 2979 sp.ControllingClient.Close();
2821 } 2980
2822 else
2823 {
2824 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2825 }
2826 // BANG! SLASH! 2981 // BANG! SLASH!
2827 m_authenticateHandler.RemoveCircuit(agentID); 2982 m_authenticateHandler.RemoveCircuit(agentID);
2828 2983
@@ -2867,6 +3022,8 @@ namespace OpenSim.Region.Framework.Scenes
2867 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3022 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2868 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3023 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2869 3024
3025 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3026
2870 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3027 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2871 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3028 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2872 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3029 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2923,6 +3080,7 @@ namespace OpenSim.Region.Framework.Scenes
2923 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3080 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2924 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3081 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2925 client.OnCopyInventoryItem += CopyInventoryItem; 3082 client.OnCopyInventoryItem += CopyInventoryItem;
3083 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2926 client.OnMoveInventoryItem += MoveInventoryItem; 3084 client.OnMoveInventoryItem += MoveInventoryItem;
2927 client.OnRemoveInventoryItem += RemoveInventoryItem; 3085 client.OnRemoveInventoryItem += RemoveInventoryItem;
2928 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3086 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2994,6 +3152,8 @@ namespace OpenSim.Region.Framework.Scenes
2994 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3152 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
2995 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3153 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
2996 3154
3155 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3156
2997 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3157 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2998 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3158 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2999 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3159 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3096,7 +3256,7 @@ namespace OpenSim.Region.Framework.Scenes
3096 /// </summary> 3256 /// </summary>
3097 /// <param name="agentId">The avatar's Unique ID</param> 3257 /// <param name="agentId">The avatar's Unique ID</param>
3098 /// <param name="client">The IClientAPI for the client</param> 3258 /// <param name="client">The IClientAPI for the client</param>
3099 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3259 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3100 { 3260 {
3101 if (EntityTransferModule != null) 3261 if (EntityTransferModule != null)
3102 { 3262 {
@@ -3107,6 +3267,7 @@ namespace OpenSim.Region.Framework.Scenes
3107 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3267 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3108 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3268 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3109 } 3269 }
3270 return false;
3110 } 3271 }
3111 3272
3112 /// <summary> 3273 /// <summary>
@@ -3216,6 +3377,16 @@ namespace OpenSim.Region.Framework.Scenes
3216 /// <param name="flags"></param> 3377 /// <param name="flags"></param>
3217 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3378 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3218 { 3379 {
3380 //Add half the avatar's height so that the user doesn't fall through prims
3381 ScenePresence presence;
3382 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3383 {
3384 if (presence.Appearance != null)
3385 {
3386 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3387 }
3388 }
3389
3219 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3390 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3220 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3391 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3221 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3392 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3332,6 +3503,7 @@ namespace OpenSim.Region.Framework.Scenes
3332 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3503 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3333 3504
3334 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3505 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3506 m_log.Debug("[Scene] The avatar has left the building");
3335 } 3507 }
3336 catch (Exception e) 3508 catch (Exception e)
3337 { 3509 {
@@ -3533,13 +3705,16 @@ namespace OpenSim.Region.Framework.Scenes
3533 sp = null; 3705 sp = null;
3534 } 3706 }
3535 3707
3536 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3537 3708
3538 //On login test land permisions 3709 //On login test land permisions
3539 if (vialogin) 3710 if (vialogin)
3540 { 3711 {
3541 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3712 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3713 if (cache != null)
3714 cache.Remove(agent.firstname + " " + agent.lastname);
3715 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3542 { 3716 {
3717 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3543 return false; 3718 return false;
3544 } 3719 }
3545 } 3720 }
@@ -3562,9 +3737,15 @@ namespace OpenSim.Region.Framework.Scenes
3562 3737
3563 try 3738 try
3564 { 3739 {
3565 if (!AuthorizeUser(agent, out reason)) 3740 // Always check estate if this is a login. Always
3566 return false; 3741 // check if banned regions are to be blacked out.
3567 } catch (Exception e) 3742 if (vialogin || (!m_seeIntoBannedRegion))
3743 {
3744 if (!AuthorizeUser(agent, out reason))
3745 return false;
3746 }
3747 }
3748 catch (Exception e)
3568 { 3749 {
3569 m_log.ErrorFormat( 3750 m_log.ErrorFormat(
3570 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3751 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@@ -3695,6 +3876,8 @@ namespace OpenSim.Region.Framework.Scenes
3695 } 3876 }
3696 3877
3697 // Honor parcel landing type and position. 3878 // Honor parcel landing type and position.
3879 /*
3880 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3698 if (land != null) 3881 if (land != null)
3699 { 3882 {
3700 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3883 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3702,25 +3885,34 @@ namespace OpenSim.Region.Framework.Scenes
3702 agent.startpos = land.LandData.UserLocation; 3885 agent.startpos = land.LandData.UserLocation;
3703 } 3886 }
3704 } 3887 }
3888 */// This is now handled properly in ScenePresence.MakeRootAgent
3705 } 3889 }
3706 3890
3707 return true; 3891 return true;
3708 } 3892 }
3709 3893
3710 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3894 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3711 { 3895 {
3712 bool banned = land.IsBannedFromLand(agent.AgentID); 3896 reason = String.Empty;
3713 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3897 if (Permissions.IsGod(agentID))
3898 return true;
3899
3900 ILandObject land = LandChannel.GetLandObject(posX, posY);
3901 if (land == null)
3902 return false;
3903
3904 bool banned = land.IsBannedFromLand(agentID);
3905 bool restricted = land.IsRestrictedFromLand(agentID);
3714 3906
3715 if (banned || restricted) 3907 if (banned || restricted)
3716 { 3908 {
3717 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3909 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3718 if (nearestParcel != null) 3910 if (nearestParcel != null)
3719 { 3911 {
3720 //Move agent to nearest allowed 3912 //Move agent to nearest allowed
3721 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3913 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3722 agent.startpos.X = newPosition.X; 3914 posX = newPosition.X;
3723 agent.startpos.Y = newPosition.Y; 3915 posY = newPosition.Y;
3724 } 3916 }
3725 else 3917 else
3726 { 3918 {
@@ -3782,7 +3974,7 @@ namespace OpenSim.Region.Framework.Scenes
3782 3974
3783 if (!m_strictAccessControl) return true; 3975 if (!m_strictAccessControl) return true;
3784 if (Permissions.IsGod(agent.AgentID)) return true; 3976 if (Permissions.IsGod(agent.AgentID)) return true;
3785 3977
3786 if (AuthorizationService != null) 3978 if (AuthorizationService != null)
3787 { 3979 {
3788 if (!AuthorizationService.IsAuthorizedForRegion( 3980 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3797,7 +3989,7 @@ namespace OpenSim.Region.Framework.Scenes
3797 3989
3798 if (RegionInfo.EstateSettings != null) 3990 if (RegionInfo.EstateSettings != null)
3799 { 3991 {
3800 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 3992 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3801 { 3993 {
3802 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3994 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3803 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3995 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3987,6 +4179,15 @@ namespace OpenSim.Region.Framework.Scenes
3987 4179
3988 // XPTO: if this agent is not allowed here as root, always return false 4180 // XPTO: if this agent is not allowed here as root, always return false
3989 4181
4182 // We have to wait until the viewer contacts this region after receiving EAC.
4183 // That calls AddNewClient, which finally creates the ScenePresence
4184 int flags = GetUserFlags(cAgentData.AgentID);
4185 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4186 {
4187 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4188 return false;
4189 }
4190
3990 // TODO: This check should probably be in QueryAccess(). 4191 // TODO: This check should probably be in QueryAccess().
3991 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4192 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3992 if (nearestParcel == null) 4193 if (nearestParcel == null)
@@ -4080,12 +4281,22 @@ namespace OpenSim.Region.Framework.Scenes
4080 return false; 4281 return false;
4081 } 4282 }
4082 4283
4284 public bool IncomingCloseAgent(UUID agentID)
4285 {
4286 return IncomingCloseAgent(agentID, false);
4287 }
4288
4289 public bool IncomingCloseChildAgent(UUID agentID)
4290 {
4291 return IncomingCloseAgent(agentID, true);
4292 }
4293
4083 /// <summary> 4294 /// <summary>
4084 /// Tell a single agent to disconnect from the region. 4295 /// Tell a single agent to disconnect from the region.
4085 /// </summary> 4296 /// </summary>
4086 /// <param name="regionHandle"></param>
4087 /// <param name="agentID"></param> 4297 /// <param name="agentID"></param>
4088 public bool IncomingCloseAgent(UUID agentID) 4298 /// <param name="childOnly"></param>
4299 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
4089 { 4300 {
4090 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4301 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4091 4302
@@ -4706,35 +4917,81 @@ namespace OpenSim.Region.Framework.Scenes
4706 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 4917 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4707 } 4918 }
4708 4919
4709 public int GetHealth() 4920 public int GetHealth(out int flags, out string message)
4710 { 4921 {
4711 // Returns: 4922 // Returns:
4712 // 1 = sim is up and accepting http requests. The heartbeat has 4923 // 1 = sim is up and accepting http requests. The heartbeat has
4713 // stopped and the sim is probably locked up, but a remote 4924 // stopped and the sim is probably locked up, but a remote
4714 // admin restart may succeed 4925 // admin restart may succeed
4715 // 4926 //
4716 // 2 = Sim is up and the heartbeat is running. The sim is likely 4927 // 2 = Sim is up and the heartbeat is running. The sim is likely
4717 // usable for people within and logins _may_ work 4928 // usable for people within
4929 //
4930 // 3 = Sim is up and one packet thread is running. Sim is
4931 // unstable and will not accept new logins
4932 //
4933 // 4 = Sim is up and both packet threads are running. Sim is
4934 // likely usable
4718 // 4935 //
4719 // 3 = We have seen a new user enter within the past 4 minutes 4936 // 5 = We have seen a new user enter within the past 4 minutes
4720 // which can be seen as positive confirmation of sim health 4937 // which can be seen as positive confirmation of sim health
4721 // 4938 //
4939
4940 flags = 0;
4941 message = String.Empty;
4942
4943 CheckHeartbeat();
4944
4945 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4946 {
4947 // We're still starting
4948 // 0 means "in startup", it can't happen another way, since
4949 // to get here, we must be able to accept http connections
4950 return 0;
4951 }
4952
4722 int health=1; // Start at 1, means we're up 4953 int health=1; // Start at 1, means we're up
4723 4954
4724 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 4955 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4725 health += 1; 4956 {
4957 health+=1;
4958 flags |= 1;
4959 }
4960
4961 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4962 {
4963 health+=1;
4964 flags |= 2;
4965 }
4966
4967 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4968 {
4969 health+=1;
4970 flags |= 4;
4971 }
4726 else 4972 else
4973 {
4974int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4975System.Diagnostics.Process proc = new System.Diagnostics.Process();
4976proc.EnableRaisingEvents=false;
4977proc.StartInfo.FileName = "/bin/kill";
4978proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4979proc.Start();
4980proc.WaitForExit();
4981Thread.Sleep(1000);
4982Environment.Exit(1);
4983 }
4984
4985 if (flags != 7)
4727 return health; 4986 return health;
4728 4987
4729 // A login in the last 4 mins? We can't be doing too badly 4988 // A login in the last 4 mins? We can't be doing too badly
4730 // 4989 //
4731 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4990 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4732 health++; 4991 health++;
4733 else 4992 else
4734 return health; 4993 return health;
4735 4994
4736// CheckHeartbeat();
4737
4738 return health; 4995 return health;
4739 } 4996 }
4740 4997
@@ -4822,7 +5079,7 @@ namespace OpenSim.Region.Framework.Scenes
4822 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5079 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4823 if (wasUsingPhysics) 5080 if (wasUsingPhysics)
4824 { 5081 {
4825 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 5082 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
4826 } 5083 }
4827 } 5084 }
4828 5085
@@ -4921,14 +5178,14 @@ namespace OpenSim.Region.Framework.Scenes
4921 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5178 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
4922 } 5179 }
4923 5180
4924// private void CheckHeartbeat() 5181 private void CheckHeartbeat()
4925// { 5182 {
4926// if (m_firstHeartbeat) 5183 if (m_firstHeartbeat)
4927// return; 5184 return;
4928// 5185
4929// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5186 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
4930// StartTimer(); 5187 Start();
4931// } 5188 }
4932 5189
4933 public override ISceneObject DeserializeObject(string representation) 5190 public override ISceneObject DeserializeObject(string representation)
4934 { 5191 {
@@ -4940,9 +5197,14 @@ namespace OpenSim.Region.Framework.Scenes
4940 get { return m_allowScriptCrossings; } 5197 get { return m_allowScriptCrossings; }
4941 } 5198 }
4942 5199
4943 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5200 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
4944 { 5201 {
4945 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5202 return GetNearestAllowedPosition(avatar, null);
5203 }
5204
5205 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5206 {
5207 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4946 5208
4947 if (nearestParcel != null) 5209 if (nearestParcel != null)
4948 { 5210 {
@@ -4951,10 +5213,7 @@ namespace OpenSim.Region.Framework.Scenes
4951 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5213 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4952 if (nearestPoint != null) 5214 if (nearestPoint != null)
4953 { 5215 {
4954// m_log.DebugFormat( 5216 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4955// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
4956// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
4957
4958 return nearestPoint.Value; 5217 return nearestPoint.Value;
4959 } 5218 }
4960 5219
@@ -4964,17 +5223,20 @@ namespace OpenSim.Region.Framework.Scenes
4964 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5223 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4965 if (nearestPoint != null) 5224 if (nearestPoint != null)
4966 { 5225 {
4967// m_log.DebugFormat( 5226 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4968// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
4969
4970 return nearestPoint.Value; 5227 return nearestPoint.Value;
4971 } 5228 }
4972 5229
4973 //Ultimate backup if we have no idea where they are 5230 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
4974// m_log.DebugFormat( 5231 if (dest != excludeParcel)
4975// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5232 {
5233 // Ultimate backup if we have no idea where they are and
5234 // the last allowed position was in another parcel
5235 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5236 return avatar.lastKnownAllowedPosition;
5237 }
4976 5238
4977 return avatar.lastKnownAllowedPosition; 5239 // else fall through to region edge
4978 } 5240 }
4979 5241
4980 //Go to the edge, this happens in teleporting to a region with no available parcels 5242 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -5008,13 +5270,18 @@ namespace OpenSim.Region.Framework.Scenes
5008 5270
5009 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5271 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5010 { 5272 {
5273 return GetNearestAllowedParcel(avatarId, x, y, null);
5274 }
5275
5276 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5277 {
5011 List<ILandObject> all = AllParcels(); 5278 List<ILandObject> all = AllParcels();
5012 float minParcelDistance = float.MaxValue; 5279 float minParcelDistance = float.MaxValue;
5013 ILandObject nearestParcel = null; 5280 ILandObject nearestParcel = null;
5014 5281
5015 foreach (var parcel in all) 5282 foreach (var parcel in all)
5016 { 5283 {
5017 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5284 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5018 { 5285 {
5019 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5286 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5020 if (parcelDistance < minParcelDistance) 5287 if (parcelDistance < minParcelDistance)
@@ -5256,7 +5523,55 @@ namespace OpenSim.Region.Framework.Scenes
5256 mapModule.GenerateMaptile(); 5523 mapModule.GenerateMaptile();
5257 } 5524 }
5258 5525
5259 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5526// public void CleanDroppedAttachments()
5527// {
5528// List<SceneObjectGroup> objectsToDelete =
5529// new List<SceneObjectGroup>();
5530//
5531// lock (m_cleaningAttachments)
5532// {
5533// ForEachSOG(delegate (SceneObjectGroup grp)
5534// {
5535// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5536// {
5537// UUID agentID = grp.OwnerID;
5538// if (agentID == UUID.Zero)
5539// {
5540// objectsToDelete.Add(grp);
5541// return;
5542// }
5543//
5544// ScenePresence sp = GetScenePresence(agentID);
5545// if (sp == null)
5546// {
5547// objectsToDelete.Add(grp);
5548// return;
5549// }
5550// }
5551// });
5552// }
5553//
5554// foreach (SceneObjectGroup grp in objectsToDelete)
5555// {
5556// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5557// DeleteSceneObject(grp, true);
5558// }
5559// }
5560
5561 public void ThreadAlive(int threadCode)
5562 {
5563 switch(threadCode)
5564 {
5565 case 1: // Incoming
5566 m_lastIncoming = Util.EnvironmentTickCount();
5567 break;
5568 case 2: // Incoming
5569 m_lastOutgoing = Util.EnvironmentTickCount();
5570 break;
5571 }
5572 }
5573
5574 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5260 { 5575 {
5261 RegenerateMaptile(); 5576 RegenerateMaptile();
5262 5577
@@ -5284,6 +5599,8 @@ namespace OpenSim.Region.Framework.Scenes
5284 /// <returns></returns> 5599 /// <returns></returns>
5285 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5600 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5286 { 5601 {
5602 reason = "You are banned from the region";
5603
5287 if (EntityTransferModule.IsInTransit(agentID)) 5604 if (EntityTransferModule.IsInTransit(agentID))
5288 { 5605 {
5289 reason = "Agent is still in transit from this region"; 5606 reason = "Agent is still in transit from this region";
@@ -5295,6 +5612,12 @@ namespace OpenSim.Region.Framework.Scenes
5295 return false; 5612 return false;
5296 } 5613 }
5297 5614
5615 if (Permissions.IsGod(agentID))
5616 {
5617 reason = String.Empty;
5618 return true;
5619 }
5620
5298 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5621 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5299 // However, the long term fix is to make sure root agent count is always accurate. 5622 // However, the long term fix is to make sure root agent count is always accurate.
5300 m_sceneGraph.RecalculateStats(); 5623 m_sceneGraph.RecalculateStats();
@@ -5315,6 +5638,41 @@ namespace OpenSim.Region.Framework.Scenes
5315 } 5638 }
5316 } 5639 }
5317 5640
5641 ScenePresence presence = GetScenePresence(agentID);
5642 IClientAPI client = null;
5643 AgentCircuitData aCircuit = null;
5644
5645 if (presence != null)
5646 {
5647 client = presence.ControllingClient;
5648 if (client != null)
5649 aCircuit = client.RequestClientInfo();
5650 }
5651
5652 // We may be called before there is a presence or a client.
5653 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5654 if (client == null)
5655 {
5656 aCircuit = new AgentCircuitData();
5657 aCircuit.AgentID = agentID;
5658 aCircuit.firstname = String.Empty;
5659 aCircuit.lastname = String.Empty;
5660 }
5661
5662 try
5663 {
5664 if (!AuthorizeUser(aCircuit, out reason))
5665 {
5666 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5667 return false;
5668 }
5669 }
5670 catch (Exception e)
5671 {
5672 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5673 return false;
5674 }
5675
5318 if (position == Vector3.Zero) // Teleport 5676 if (position == Vector3.Zero) // Teleport
5319 { 5677 {
5320 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5678 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5343,13 +5701,46 @@ namespace OpenSim.Region.Framework.Scenes
5343 } 5701 }
5344 } 5702 }
5345 } 5703 }
5704
5705 float posX = 128.0f;
5706 float posY = 128.0f;
5707
5708 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5709 {
5710 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5711 return false;
5712 }
5713 }
5714 else // Walking
5715 {
5716 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5717 if (land == null)
5718 return false;
5719
5720 bool banned = land.IsBannedFromLand(agentID);
5721 bool restricted = land.IsRestrictedFromLand(agentID);
5722
5723 if (banned || restricted)
5724 return false;
5346 } 5725 }
5347 5726
5348 reason = String.Empty; 5727 reason = String.Empty;
5349 return true; 5728 return true;
5350 } 5729 }
5351 5730
5352 /// <summary> 5731 public void StartTimerWatchdog()
5732 {
5733 m_timerWatchdog.Interval = 1000;
5734 m_timerWatchdog.Elapsed += TimerWatchdog;
5735 m_timerWatchdog.AutoReset = true;
5736 m_timerWatchdog.Start();
5737 }
5738
5739 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5740 {
5741 CheckHeartbeat();
5742 }
5743
5353 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5744 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5354 /// autopilot that moves an avatar to a sit target!. 5745 /// autopilot that moves an avatar to a sit target!.
5355 /// </summary> 5746 /// </summary>
@@ -5428,6 +5819,11 @@ namespace OpenSim.Region.Framework.Scenes
5428 return m_SpawnPoint - 1; 5819 return m_SpawnPoint - 1;
5429 } 5820 }
5430 5821
5822 private void HandleGcCollect(string module, string[] args)
5823 {
5824 GC.Collect();
5825 }
5826
5431 // Wrappers to get physics modules retrieve assets. Has to be done this way 5827 // Wrappers to get physics modules retrieve assets. Has to be done this way
5432 // because we can't assign the asset service to physics directly - at the 5828 // because we can't assign the asset service to physics directly - at the
5433 // time physics are instantiated it's not registered but it will be by 5829 // time physics are instantiated it's not registered but it will be by