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.cs858
1 files changed, 627 insertions, 231 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 69c1027..4282b46 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -156,8 +156,8 @@ namespace OpenSim.Region.Framework.Scenes
156 // TODO: need to figure out how allow client agents but deny 156 // TODO: need to figure out how allow client agents but deny
157 // root agents when ACL denies access to root agent 157 // root agents when ACL denies access to root agent
158 public bool m_strictAccessControl = true; 158 public bool m_strictAccessControl = true;
159 159 public bool m_seeIntoBannedRegion = false;
160 public int MaxUndoCount { get; set; } 160 public int MaxUndoCount = 5;
161 161
162 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 162 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
163 public bool LoginLock = false; 163 public bool LoginLock = false;
@@ -173,12 +173,14 @@ namespace OpenSim.Region.Framework.Scenes
173 173
174 protected int m_splitRegionID; 174 protected int m_splitRegionID;
175 protected Timer m_restartWaitTimer = new Timer(); 175 protected Timer m_restartWaitTimer = new Timer();
176 protected Timer m_timerWatchdog = new Timer();
176 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 177 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
177 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 178 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
178 protected string m_simulatorVersion = "OpenSimulator Server"; 179 protected string m_simulatorVersion = "OpenSimulator Server";
179 protected ModuleLoader m_moduleLoader; 180 protected ModuleLoader m_moduleLoader;
180 protected AgentCircuitManager m_authenticateHandler; 181 protected AgentCircuitManager m_authenticateHandler;
181 protected SceneCommunicationService m_sceneGridService; 182 protected SceneCommunicationService m_sceneGridService;
183 protected ISnmpModule m_snmpService = null;
182 184
183 protected ISimulationDataService m_SimulationDataService; 185 protected ISimulationDataService m_SimulationDataService;
184 protected IEstateDataService m_EstateDataService; 186 protected IEstateDataService m_EstateDataService;
@@ -241,8 +243,8 @@ namespace OpenSim.Region.Framework.Scenes
241 private int m_update_presences = 1; // Update scene presence movements 243 private int m_update_presences = 1; // Update scene presence movements
242 private int m_update_events = 1; 244 private int m_update_events = 1;
243 private int m_update_backup = 200; 245 private int m_update_backup = 200;
244 private int m_update_terrain = 50; 246 private int m_update_terrain = 1000;
245// private int m_update_land = 1; 247 private int m_update_land = 10;
246 private int m_update_coarse_locations = 50; 248 private int m_update_coarse_locations = 50;
247 249
248 private int agentMS; 250 private int agentMS;
@@ -255,13 +257,13 @@ namespace OpenSim.Region.Framework.Scenes
255 private int backupMS; 257 private int backupMS;
256 private int terrainMS; 258 private int terrainMS;
257 private int landMS; 259 private int landMS;
258 private int spareMS;
259 260
260 /// <summary> 261 /// <summary>
261 /// Tick at which the last frame was processed. 262 /// Tick at which the last frame was processed.
262 /// </summary> 263 /// </summary>
263 private int m_lastFrameTick; 264 private int m_lastFrameTick;
264 265
266 public bool CombineRegions = false;
265 /// <summary> 267 /// <summary>
266 /// Tick at which the last maintenance run occurred. 268 /// Tick at which the last maintenance run occurred.
267 /// </summary> 269 /// </summary>
@@ -292,6 +294,11 @@ namespace OpenSim.Region.Framework.Scenes
292 /// </summary> 294 /// </summary>
293 private int m_LastLogin; 295 private int m_LastLogin;
294 296
297 private int m_lastIncoming;
298 private int m_lastOutgoing;
299 private int m_hbRestarts = 0;
300
301
295 /// <summary> 302 /// <summary>
296 /// Thread that runs the scene loop. 303 /// Thread that runs the scene loop.
297 /// </summary> 304 /// </summary>
@@ -332,7 +339,7 @@ namespace OpenSim.Region.Framework.Scenes
332 private volatile bool m_active; 339 private volatile bool m_active;
333 340
334// private int m_lastUpdate; 341// private int m_lastUpdate;
335// private bool m_firstHeartbeat = true; 342 private bool m_firstHeartbeat = true;
336 343
337 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 344 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
338 private bool m_reprioritizationEnabled = true; 345 private bool m_reprioritizationEnabled = true;
@@ -377,6 +384,19 @@ namespace OpenSim.Region.Framework.Scenes
377 get { return m_sceneGridService; } 384 get { return m_sceneGridService; }
378 } 385 }
379 386
387 public ISnmpModule SnmpService
388 {
389 get
390 {
391 if (m_snmpService == null)
392 {
393 m_snmpService = RequestModuleInterface<ISnmpModule>();
394 }
395
396 return m_snmpService;
397 }
398 }
399
380 public ISimulationDataService SimulationDataService 400 public ISimulationDataService SimulationDataService
381 { 401 {
382 get 402 get
@@ -676,6 +696,8 @@ namespace OpenSim.Region.Framework.Scenes
676 m_SimulationDataService = simDataService; 696 m_SimulationDataService = simDataService;
677 m_EstateDataService = estateDataService; 697 m_EstateDataService = estateDataService;
678 m_regionHandle = RegionInfo.RegionHandle; 698 m_regionHandle = RegionInfo.RegionHandle;
699 m_lastIncoming = 0;
700 m_lastOutgoing = 0;
679 701
680 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 702 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
681 m_asyncSceneObjectDeleter.Enabled = true; 703 m_asyncSceneObjectDeleter.Enabled = true;
@@ -758,132 +780,141 @@ namespace OpenSim.Region.Framework.Scenes
758 780
759 // Region config overrides global config 781 // Region config overrides global config
760 // 782 //
761 if (m_config.Configs["Startup"] != null) 783 try
762 { 784 {
763 IConfig startupConfig = m_config.Configs["Startup"]; 785 if (m_config.Configs["Startup"] != null)
764
765 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
766
767 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
768 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
769 if (!m_useBackup)
770 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
771
772 //Animation states
773 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
774
775 MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20);
776
777 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
778 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
779
780 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
781 if (RegionInfo.NonphysPrimMin > 0)
782 { 786 {
783 m_minNonphys = RegionInfo.NonphysPrimMin; 787 IConfig startupConfig = m_config.Configs["Startup"];
784 }
785 788
786 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 789 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
787 if (RegionInfo.NonphysPrimMax > 0)
788 {
789 m_maxNonphys = RegionInfo.NonphysPrimMax;
790 }
791 790
792 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); 791 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
793 if (RegionInfo.PhysPrimMin > 0) 792 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
794 { 793 if (!m_useBackup)
795 m_minPhys = RegionInfo.PhysPrimMin; 794 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
796 } 795
796 //Animation states
797 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
797 798
798 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 799 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
799 if (RegionInfo.PhysPrimMax > 0) 800 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
800 {
801 m_maxPhys = RegionInfo.PhysPrimMax;
802 }
803 801
804 // Here, if clamping is requested in either global or 802 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
805 // local config, it will be used 803 if (RegionInfo.NonphysPrimMin > 0)
806 // 804 {
807 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); 805 m_minNonphys = RegionInfo.NonphysPrimMin;
808 if (RegionInfo.ClampPrimSize) 806 }
809 {
810 m_clampPrimSize = true;
811 }
812 807
813 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 808 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
814 if (RegionInfo.LinksetCapacity > 0) 809 if (RegionInfo.NonphysPrimMax > 0)
815 { 810 {
816 m_linksetCapacity = RegionInfo.LinksetCapacity; 811 m_maxNonphys = RegionInfo.NonphysPrimMax;
817 } 812 }
818 813
819 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 814 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
820 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 815 if (RegionInfo.PhysPrimMin > 0)
821 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 816 {
822 m_dontPersistBefore = 817 m_minPhys = RegionInfo.PhysPrimMin;
823 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); 818 }
824 m_dontPersistBefore *= 10000000;
825 m_persistAfter =
826 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
827 m_persistAfter *= 10000000;
828 819
829 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 820 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
830 821
831 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 822 if (RegionInfo.PhysPrimMax > 0)
832 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 823 {
824 m_maxPhys = RegionInfo.PhysPrimMax;
825 }
833 826
834 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 827 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
828 if (RegionInfo.LinksetCapacity > 0)
829 {
830 m_linksetCapacity = RegionInfo.LinksetCapacity;
831 }
835 832
836 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 833 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
837 if (m_generateMaptiles) 834 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
838 { 835
839 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 836 // Here, if clamping is requested in either global or
840 if (maptileRefresh != 0) 837 // local config, it will be used
838 //
839 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
840 if (RegionInfo.ClampPrimSize)
841 { 841 {
842 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 842 m_clampPrimSize = true;
843 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
844 m_mapGenerationTimer.AutoReset = true;
845 m_mapGenerationTimer.Start();
846 } 843 }
847 }
848 else
849 {
850 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
851 UUID tileID;
852 844
853 if (UUID.TryParse(tile, out tileID)) 845 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
846 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
847 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
848 m_dontPersistBefore =
849 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
850 m_dontPersistBefore *= 10000000;
851 m_persistAfter =
852 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
853 m_persistAfter *= 10000000;
854
855 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
856 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
857
858 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
859 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
860 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
861
862 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
863 if (m_generateMaptiles)
854 { 864 {
855 RegionInfo.RegionSettings.TerrainImageID = tileID; 865 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
866 if (maptileRefresh != 0)
867 {
868 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
869 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
870 m_mapGenerationTimer.AutoReset = true;
871 m_mapGenerationTimer.Start();
872 }
856 } 873 }
857 } 874 else
875 {
876 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
877 UUID tileID;
858 878
859 string grant = startupConfig.GetString("AllowedClients", String.Empty); 879 if (UUID.TryParse(tile, out tileID))
860 if (grant.Length > 0) 880 {
861 { 881 RegionInfo.RegionSettings.TerrainImageID = tileID;
862 foreach (string viewer in grant.Split('|')) 882 }
883 }
884
885 string grant = startupConfig.GetString("AllowedClients", String.Empty);
886 if (grant.Length > 0)
863 { 887 {
864 m_AllowedViewers.Add(viewer.Trim().ToLower()); 888 foreach (string viewer in grant.Split(','))
889 {
890 m_AllowedViewers.Add(viewer.Trim().ToLower());
891 }
865 } 892 }
866 }
867 893
868 grant = startupConfig.GetString("BannedClients", String.Empty); 894 grant = startupConfig.GetString("BannedClients", String.Empty);
869 if (grant.Length > 0) 895 if (grant.Length > 0)
870 {
871 foreach (string viewer in grant.Split('|'))
872 { 896 {
873 m_BannedViewers.Add(viewer.Trim().ToLower()); 897 foreach (string viewer in grant.Split(','))
898 {
899 m_BannedViewers.Add(viewer.Trim().ToLower());
900 }
874 } 901 }
875 }
876 902
877 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 903 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
878 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 904 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
879 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 905 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
880 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 906 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
881 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 907 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
882 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); 908 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
883 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); 909 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
884 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); 910 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
885 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 911 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
886 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 912 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
913 }
914 }
915 catch (Exception e)
916 {
917 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
887 } 918 }
888 919
889 // FIXME: Ultimately this should be in a module. 920 // FIXME: Ultimately this should be in a module.
@@ -928,6 +959,8 @@ namespace OpenSim.Region.Framework.Scenes
928 StatsReporter = new SimStatsReporter(this); 959 StatsReporter = new SimStatsReporter(this);
929 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 960 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
930 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 961 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
962
963 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
931 } 964 }
932 965
933 public Scene(RegionInfo regInfo) : base(regInfo) 966 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1348,7 +1381,22 @@ namespace OpenSim.Region.Framework.Scenes
1348 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1381 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1349 if (m_heartbeatThread != null) 1382 if (m_heartbeatThread != null)
1350 { 1383 {
1384 m_hbRestarts++;
1385 if(m_hbRestarts > 10)
1386 Environment.Exit(1);
1387 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1388
1389//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1390//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1391//proc.EnableRaisingEvents=false;
1392//proc.StartInfo.FileName = "/bin/kill";
1393//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1394//proc.Start();
1395//proc.WaitForExit();
1396//Thread.Sleep(1000);
1397//Environment.Exit(1);
1351 m_heartbeatThread.Abort(); 1398 m_heartbeatThread.Abort();
1399 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1352 m_heartbeatThread = null; 1400 m_heartbeatThread = null;
1353 } 1401 }
1354// m_lastUpdate = Util.EnvironmentTickCount(); 1402// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1495,16 +1543,20 @@ namespace OpenSim.Region.Framework.Scenes
1495 endFrame = Frame + frames; 1543 endFrame = Frame + frames;
1496 1544
1497 float physicsFPS = 0f; 1545 float physicsFPS = 0f;
1498 int previousFrameTick, tmpMS; 1546 int tmpMS;
1499 int maintc = Util.EnvironmentTickCount(); 1547 int previousFrameTick;
1548 int maintc;
1549 int sleepMS;
1550 int framestart;
1500 1551
1501 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1552 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1502 { 1553 {
1554 framestart = Util.EnvironmentTickCount();
1503 ++Frame; 1555 ++Frame;
1504 1556
1505// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1557// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1506 1558
1507 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1559 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1508 1560
1509 try 1561 try
1510 { 1562 {
@@ -1556,6 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes
1556 m_sceneGraph.UpdatePresences(); 1608 m_sceneGraph.UpdatePresences();
1557 1609
1558 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1610 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1611
1559 1612
1560 // Delete temp-on-rez stuff 1613 // Delete temp-on-rez stuff
1561 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1614 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1637,34 +1690,37 @@ namespace OpenSim.Region.Framework.Scenes
1637 1690
1638 Watchdog.UpdateThread(); 1691 Watchdog.UpdateThread();
1639 1692
1693 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1694
1695 StatsReporter.AddPhysicsFPS(physicsFPS);
1696 StatsReporter.AddTimeDilation(TimeDilation);
1697 StatsReporter.AddFPS(1);
1698
1699 StatsReporter.addAgentMS(agentMS);
1700 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1701 StatsReporter.addOtherMS(otherMS);
1702 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1703
1640 previousFrameTick = m_lastFrameTick; 1704 previousFrameTick = m_lastFrameTick;
1641 m_lastFrameTick = Util.EnvironmentTickCount(); 1705 m_lastFrameTick = Util.EnvironmentTickCount();
1642 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1706 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1643 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1707 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1644 1708
1709 m_firstHeartbeat = false;
1710
1711 sleepMS = Util.EnvironmentTickCount();
1712
1645 if (tmpMS > 0) 1713 if (tmpMS > 0)
1646 {
1647 Thread.Sleep(tmpMS); 1714 Thread.Sleep(tmpMS);
1648 spareMS += tmpMS;
1649 }
1650
1651 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1652 maintc = Util.EnvironmentTickCount();
1653 1715
1654 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1716 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1717 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1718 StatsReporter.addSleepMS(sleepMS);
1719 StatsReporter.addFrameMS(frameMS);
1655 1720
1656 // if (Frame%m_update_avatars == 0) 1721 // if (Frame%m_update_avatars == 0)
1657 // UpdateInWorldTime(); 1722 // UpdateInWorldTime();
1658 StatsReporter.AddPhysicsFPS(physicsFPS);
1659 StatsReporter.AddTimeDilation(TimeDilation);
1660 StatsReporter.AddFPS(1);
1661 1723
1662 StatsReporter.addFrameMS(frameMS);
1663 StatsReporter.addAgentMS(agentMS);
1664 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1665 StatsReporter.addOtherMS(otherMS);
1666 StatsReporter.AddSpareMS(spareMS);
1667 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1668 1724
1669 // Optionally warn if a frame takes double the amount of time that it should. 1725 // Optionally warn if a frame takes double the amount of time that it should.
1670 if (DebugUpdates 1726 if (DebugUpdates
@@ -1782,7 +1838,7 @@ namespace OpenSim.Region.Framework.Scenes
1782 msg.fromAgentName = "Server"; 1838 msg.fromAgentName = "Server";
1783 msg.dialog = (byte)19; // Object msg 1839 msg.dialog = (byte)19; // Object msg
1784 msg.fromGroup = false; 1840 msg.fromGroup = false;
1785 msg.offline = (byte)0; 1841 msg.offline = (byte)1;
1786 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1842 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1787 msg.Position = Vector3.Zero; 1843 msg.Position = Vector3.Zero;
1788 msg.RegionID = RegionInfo.RegionID.Guid; 1844 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -2004,6 +2060,19 @@ namespace OpenSim.Region.Framework.Scenes
2004 EventManager.TriggerPrimsLoaded(this); 2060 EventManager.TriggerPrimsLoaded(this);
2005 } 2061 }
2006 2062
2063 public bool SuportsRayCastFiltered()
2064 {
2065 if (PhysicsScene == null)
2066 return false;
2067 return PhysicsScene.SuportsRaycastWorldFiltered();
2068 }
2069
2070 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2071 {
2072 if (PhysicsScene == null)
2073 return null;
2074 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
2075 }
2007 2076
2008 /// <summary> 2077 /// <summary>
2009 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 2078 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -2020,14 +2089,24 @@ namespace OpenSim.Region.Framework.Scenes
2020 /// <returns></returns> 2089 /// <returns></returns>
2021 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2090 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
2022 { 2091 {
2092
2093 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2094 Vector3 wpos = Vector3.Zero;
2095 // Check for water surface intersection from above
2096 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2097 {
2098 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2099 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2100 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2101 wpos.Z = wheight;
2102 }
2103
2023 Vector3 pos = Vector3.Zero; 2104 Vector3 pos = Vector3.Zero;
2024 if (RayEndIsIntersection == (byte)1) 2105 if (RayEndIsIntersection == (byte)1)
2025 { 2106 {
2026 pos = RayEnd; 2107 pos = RayEnd;
2027 return pos;
2028 } 2108 }
2029 2109 else if (RayTargetID != UUID.Zero)
2030 if (RayTargetID != UUID.Zero)
2031 { 2110 {
2032 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2111 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
2033 2112
@@ -2049,7 +2128,7 @@ namespace OpenSim.Region.Framework.Scenes
2049 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2128 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2050 2129
2051 // Un-comment out the following line to Get Raytrace results printed to the console. 2130 // Un-comment out the following line to Get Raytrace results printed to the console.
2052 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2131 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2053 float ScaleOffset = 0.5f; 2132 float ScaleOffset = 0.5f;
2054 2133
2055 // If we hit something 2134 // If we hit something
@@ -2072,13 +2151,10 @@ namespace OpenSim.Region.Framework.Scenes
2072 //pos.Z -= 0.25F; 2151 //pos.Z -= 0.25F;
2073 2152
2074 } 2153 }
2075
2076 return pos;
2077 } 2154 }
2078 else 2155 else
2079 { 2156 {
2080 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2157 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2081
2082 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2158 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2083 2159
2084 // Un-comment the following line to print the raytrace results to the console. 2160 // Un-comment the following line to print the raytrace results to the console.
@@ -2087,13 +2163,12 @@ namespace OpenSim.Region.Framework.Scenes
2087 if (ei.HitTF) 2163 if (ei.HitTF)
2088 { 2164 {
2089 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2165 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2090 } else 2166 }
2167 else
2091 { 2168 {
2092 // fall back to our stupid functionality 2169 // fall back to our stupid functionality
2093 pos = RayEnd; 2170 pos = RayEnd;
2094 } 2171 }
2095
2096 return pos;
2097 } 2172 }
2098 } 2173 }
2099 else 2174 else
@@ -2104,8 +2179,12 @@ namespace OpenSim.Region.Framework.Scenes
2104 //increase height so its above the ground. 2179 //increase height so its above the ground.
2105 //should be getting the normal of the ground at the rez point and using that? 2180 //should be getting the normal of the ground at the rez point and using that?
2106 pos.Z += scale.Z / 2f; 2181 pos.Z += scale.Z / 2f;
2107 return pos; 2182// return pos;
2108 } 2183 }
2184
2185 // check against posible water intercept
2186 if (wpos.Z > pos.Z) pos = wpos;
2187 return pos;
2109 } 2188 }
2110 2189
2111 2190
@@ -2196,12 +2275,12 @@ namespace OpenSim.Region.Framework.Scenes
2196 { 2275 {
2197 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) 2276 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2198 { 2277 {
2278 sceneObject.IsDeleted = false;
2199 EventManager.TriggerObjectAddedToScene(sceneObject); 2279 EventManager.TriggerObjectAddedToScene(sceneObject);
2200 return true; 2280 return true;
2201 } 2281 }
2202 2282
2203 return false; 2283 return false;
2204
2205 } 2284 }
2206 2285
2207 /// <summary> 2286 /// <summary>
@@ -2293,6 +2372,15 @@ namespace OpenSim.Region.Framework.Scenes
2293 /// </summary> 2372 /// </summary>
2294 public void DeleteAllSceneObjects() 2373 public void DeleteAllSceneObjects()
2295 { 2374 {
2375 DeleteAllSceneObjects(false);
2376 }
2377
2378 /// <summary>
2379 /// Delete every object from the scene. This does not include attachments worn by avatars.
2380 /// </summary>
2381 public void DeleteAllSceneObjects(bool exceptNoCopy)
2382 {
2383 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2296 lock (Entities) 2384 lock (Entities)
2297 { 2385 {
2298 EntityBase[] entities = Entities.GetEntities(); 2386 EntityBase[] entities = Entities.GetEntities();
@@ -2301,11 +2389,24 @@ namespace OpenSim.Region.Framework.Scenes
2301 if (e is SceneObjectGroup) 2389 if (e is SceneObjectGroup)
2302 { 2390 {
2303 SceneObjectGroup sog = (SceneObjectGroup)e; 2391 SceneObjectGroup sog = (SceneObjectGroup)e;
2304 if (!sog.IsAttachment) 2392 if (sog != null && !sog.IsAttachment)
2305 DeleteSceneObject((SceneObjectGroup)e, false); 2393 {
2394 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2395 {
2396 DeleteSceneObject((SceneObjectGroup)e, false);
2397 }
2398 else
2399 {
2400 toReturn.Add((SceneObjectGroup)e);
2401 }
2402 }
2306 } 2403 }
2307 } 2404 }
2308 } 2405 }
2406 if (toReturn.Count > 0)
2407 {
2408 returnObjects(toReturn.ToArray(), UUID.Zero);
2409 }
2309 } 2410 }
2310 2411
2311 /// <summary> 2412 /// <summary>
@@ -2340,6 +2441,12 @@ namespace OpenSim.Region.Framework.Scenes
2340 2441
2341 foreach (SceneObjectPart part in partList) 2442 foreach (SceneObjectPart part in partList)
2342 { 2443 {
2444 if (part.KeyframeMotion != null)
2445 {
2446 part.KeyframeMotion.Delete();
2447 part.KeyframeMotion = null;
2448 }
2449
2343 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) 2450 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
2344 { 2451 {
2345 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? 2452 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
@@ -2357,6 +2464,8 @@ namespace OpenSim.Region.Framework.Scenes
2357 } 2464 }
2358 2465
2359 group.DeleteGroupFromScene(silent); 2466 group.DeleteGroupFromScene(silent);
2467 if (!silent)
2468 SendKillObject(new List<uint>() { group.LocalId });
2360 2469
2361// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2470// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2362 } 2471 }
@@ -2647,7 +2756,7 @@ namespace OpenSim.Region.Framework.Scenes
2647 // If the user is banned, we won't let any of their objects 2756 // If the user is banned, we won't let any of their objects
2648 // enter. Period. 2757 // enter. Period.
2649 // 2758 //
2650 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2759 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2651 { 2760 {
2652 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2761 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2653 return false; 2762 return false;
@@ -2655,6 +2764,8 @@ namespace OpenSim.Region.Framework.Scenes
2655 2764
2656 if (newPosition != Vector3.Zero) 2765 if (newPosition != Vector3.Zero)
2657 newObject.RootPart.GroupPosition = newPosition; 2766 newObject.RootPart.GroupPosition = newPosition;
2767 if (newObject.RootPart.KeyframeMotion != null)
2768 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2658 2769
2659 if (!AddSceneObject(newObject)) 2770 if (!AddSceneObject(newObject))
2660 { 2771 {
@@ -2699,6 +2810,23 @@ namespace OpenSim.Region.Framework.Scenes
2699 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2810 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2700 public bool AddSceneObject(SceneObjectGroup sceneObject) 2811 public bool AddSceneObject(SceneObjectGroup sceneObject)
2701 { 2812 {
2813 if (sceneObject.OwnerID == UUID.Zero)
2814 {
2815 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2816 return false;
2817 }
2818
2819 // If the user is banned, we won't let any of their objects
2820 // enter. Period.
2821 //
2822 int flags = GetUserFlags(sceneObject.OwnerID);
2823 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2824 {
2825 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2826
2827 return false;
2828 }
2829
2702 // Force allocation of new LocalId 2830 // Force allocation of new LocalId
2703 // 2831 //
2704 SceneObjectPart[] parts = sceneObject.Parts; 2832 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2732,16 +2860,27 @@ namespace OpenSim.Region.Framework.Scenes
2732 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2860 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2733 2861
2734 if (AttachmentsModule != null) 2862 if (AttachmentsModule != null)
2735 AttachmentsModule.AttachObject(sp, grp, 0, false, false); 2863 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false);
2736 } 2864 }
2737 else 2865 else
2738 { 2866 {
2867 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2739 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2868 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2740 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2869 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2741 } 2870 }
2871 if (sceneObject.OwnerID == UUID.Zero)
2872 {
2873 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2874 return false;
2875 }
2742 } 2876 }
2743 else 2877 else
2744 { 2878 {
2879 if (sceneObject.OwnerID == UUID.Zero)
2880 {
2881 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2882 return false;
2883 }
2745 AddRestoredSceneObject(sceneObject, true, false); 2884 AddRestoredSceneObject(sceneObject, true, false);
2746 } 2885 }
2747 2886
@@ -2758,6 +2897,24 @@ namespace OpenSim.Region.Framework.Scenes
2758 return 2; // StateSource.PrimCrossing 2897 return 2; // StateSource.PrimCrossing
2759 } 2898 }
2760 2899
2900 public int GetUserFlags(UUID user)
2901 {
2902 //Unfortunately the SP approach means that the value is cached until region is restarted
2903 /*
2904 ScenePresence sp;
2905 if (TryGetScenePresence(user, out sp))
2906 {
2907 return sp.UserFlags;
2908 }
2909 else
2910 {
2911 */
2912 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2913 if (uac == null)
2914 return 0;
2915 return uac.UserFlags;
2916 //}
2917 }
2761 #endregion 2918 #endregion
2762 2919
2763 #region Add/Remove Avatar Methods 2920 #region Add/Remove Avatar Methods
@@ -2790,7 +2947,7 @@ namespace OpenSim.Region.Framework.Scenes
2790 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2947 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2791 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2948 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2792 2949
2793 // CheckHeartbeat(); 2950 CheckHeartbeat();
2794 2951
2795 sp = GetScenePresence(client.AgentId); 2952 sp = GetScenePresence(client.AgentId);
2796 2953
@@ -2934,19 +3091,14 @@ namespace OpenSim.Region.Framework.Scenes
2934 // and the scene presence and the client, if they exist 3091 // and the scene presence and the client, if they exist
2935 try 3092 try
2936 { 3093 {
2937 // We need to wait for the client to make UDP contact first. 3094 ScenePresence sp = GetScenePresence(agentID);
2938 // It's the UDP contact that creates the scene presence 3095
2939 ScenePresence sp = WaitGetScenePresence(agentID);
2940 if (sp != null) 3096 if (sp != null)
2941 { 3097 {
2942 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3098 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2943
2944 sp.ControllingClient.Close(); 3099 sp.ControllingClient.Close();
2945 } 3100 }
2946 else 3101
2947 {
2948 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2949 }
2950 // BANG! SLASH! 3102 // BANG! SLASH!
2951 m_authenticateHandler.RemoveCircuit(agentID); 3103 m_authenticateHandler.RemoveCircuit(agentID);
2952 3104
@@ -2991,6 +3143,8 @@ namespace OpenSim.Region.Framework.Scenes
2991 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3143 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2992 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3144 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2993 3145
3146 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3147
2994 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3148 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2995 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3149 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2996 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3150 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -3047,6 +3201,7 @@ namespace OpenSim.Region.Framework.Scenes
3047 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3201 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
3048 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3202 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
3049 client.OnCopyInventoryItem += CopyInventoryItem; 3203 client.OnCopyInventoryItem += CopyInventoryItem;
3204 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
3050 client.OnMoveInventoryItem += MoveInventoryItem; 3205 client.OnMoveInventoryItem += MoveInventoryItem;
3051 client.OnRemoveInventoryItem += RemoveInventoryItem; 3206 client.OnRemoveInventoryItem += RemoveInventoryItem;
3052 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3207 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3118,6 +3273,8 @@ namespace OpenSim.Region.Framework.Scenes
3118 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3273 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3119 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3274 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3120 3275
3276 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3277
3121 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3278 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3122 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3279 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3123 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3280 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3220,7 +3377,7 @@ namespace OpenSim.Region.Framework.Scenes
3220 /// </summary> 3377 /// </summary>
3221 /// <param name="agentId">The avatar's Unique ID</param> 3378 /// <param name="agentId">The avatar's Unique ID</param>
3222 /// <param name="client">The IClientAPI for the client</param> 3379 /// <param name="client">The IClientAPI for the client</param>
3223 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3380 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3224 { 3381 {
3225 if (EntityTransferModule != null) 3382 if (EntityTransferModule != null)
3226 { 3383 {
@@ -3231,6 +3388,7 @@ namespace OpenSim.Region.Framework.Scenes
3231 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3388 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3232 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3389 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3233 } 3390 }
3391 return false;
3234 } 3392 }
3235 3393
3236 /// <summary> 3394 /// <summary>
@@ -3340,6 +3498,16 @@ namespace OpenSim.Region.Framework.Scenes
3340 /// <param name="flags"></param> 3498 /// <param name="flags"></param>
3341 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3499 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3342 { 3500 {
3501 //Add half the avatar's height so that the user doesn't fall through prims
3502 ScenePresence presence;
3503 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3504 {
3505 if (presence.Appearance != null)
3506 {
3507 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3508 }
3509 }
3510
3343 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3511 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3344 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3512 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3345 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3513 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3477,6 +3645,7 @@ namespace OpenSim.Region.Framework.Scenes
3477 // It's possible for child agents to have transactions if changes are being made cross-border. 3645 // It's possible for child agents to have transactions if changes are being made cross-border.
3478 if (AgentTransactionsModule != null) 3646 if (AgentTransactionsModule != null)
3479 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3647 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3648 m_log.Debug("[Scene] The avatar has left the building");
3480 } 3649 }
3481 catch (Exception e) 3650 catch (Exception e)
3482 { 3651 {
@@ -3669,38 +3838,39 @@ namespace OpenSim.Region.Framework.Scenes
3669 agent.firstname, agent.lastname, agent.Viewer); 3838 agent.firstname, agent.lastname, agent.Viewer);
3670 reason = "Access denied, your viewer is banned by the region owner"; 3839 reason = "Access denied, your viewer is banned by the region owner";
3671 return false; 3840 return false;
3672 } 3841 }
3842
3673 3843
3674 ILandObject land; 3844 ScenePresence sp = GetScenePresence(agent.AgentID);
3845
3846 if (sp != null && !sp.IsChildAgent)
3847 {
3848 // We have a zombie from a crashed session.
3849 // Or the same user is trying to be root twice here, won't work.
3850 // Kill it.
3851 m_log.WarnFormat(
3852 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3853 sp.Name, sp.UUID, RegionInfo.RegionName);
3854
3855 sp.ControllingClient.Close(true, true);
3856 sp = null;
3857 }
3675 3858
3676 lock (agent) 3859 lock (agent)
3677 { 3860 {
3678 ScenePresence sp = GetScenePresence(agent.AgentID);
3679
3680 if (sp != null && !sp.IsChildAgent)
3681 {
3682 // We have a zombie from a crashed session.
3683 // Or the same user is trying to be root twice here, won't work.
3684 // Kill it.
3685 m_log.WarnFormat(
3686 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3687 sp.Name, sp.UUID, RegionInfo.RegionName);
3688
3689 sp.ControllingClient.Close(true);
3690 sp = null;
3691 }
3692
3693 land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3694
3695 //On login test land permisions 3861 //On login test land permisions
3696 if (vialogin) 3862 if (vialogin)
3697 { 3863 {
3698 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3864 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3865 if (cache != null)
3866 cache.Remove(agent.firstname + " " + agent.lastname);
3867 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3699 { 3868 {
3869 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3700 return false; 3870 return false;
3701 } 3871 }
3702 } 3872 }
3703 3873
3704 if (sp == null) // We don't have an [child] agent here already 3874 if (sp == null) // We don't have an [child] agent here already
3705 { 3875 {
3706 if (requirePresenceLookup) 3876 if (requirePresenceLookup)
@@ -3709,34 +3879,36 @@ namespace OpenSim.Region.Framework.Scenes
3709 { 3879 {
3710 if (!VerifyUserPresence(agent, out reason)) 3880 if (!VerifyUserPresence(agent, out reason))
3711 return false; 3881 return false;
3712 } 3882 } catch (Exception e)
3713 catch (Exception e)
3714 { 3883 {
3715 m_log.ErrorFormat( 3884 m_log.ErrorFormat(
3716 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3885 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
3717
3718 return false; 3886 return false;
3719 } 3887 }
3720 } 3888 }
3721 3889
3722 try 3890 try
3723 { 3891 {
3724 if (!AuthorizeUser(agent, out reason)) 3892 // Always check estate if this is a login. Always
3725 return false; 3893 // check if banned regions are to be blacked out.
3894 if (vialogin || (!m_seeIntoBannedRegion))
3895 {
3896 if (!AuthorizeUser(agent, out reason))
3897 return false;
3898 }
3726 } 3899 }
3727 catch (Exception e) 3900 catch (Exception e)
3728 { 3901 {
3729 m_log.ErrorFormat( 3902 m_log.ErrorFormat(
3730 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3903 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
3731
3732 return false; 3904 return false;
3733 } 3905 }
3734 3906
3735 m_log.InfoFormat( 3907 m_log.InfoFormat(
3736 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 3908 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3737 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3909 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3738 agent.AgentID, agent.circuitcode); 3910 agent.AgentID, agent.circuitcode);
3739 3911
3740 if (CapsModule != null) 3912 if (CapsModule != null)
3741 { 3913 {
3742 CapsModule.SetAgentCapsSeeds(agent); 3914 CapsModule.SetAgentCapsSeeds(agent);
@@ -3748,15 +3920,15 @@ namespace OpenSim.Region.Framework.Scenes
3748 // Let the SP know how we got here. This has a lot of interesting 3920 // Let the SP know how we got here. This has a lot of interesting
3749 // uses down the line. 3921 // uses down the line.
3750 sp.TeleportFlags = (TPFlags)teleportFlags; 3922 sp.TeleportFlags = (TPFlags)teleportFlags;
3751 3923
3752 if (sp.IsChildAgent) 3924 if (sp.IsChildAgent)
3753 { 3925 {
3754 m_log.DebugFormat( 3926 m_log.DebugFormat(
3755 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", 3927 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
3756 agent.AgentID, RegionInfo.RegionName); 3928 agent.AgentID, RegionInfo.RegionName);
3757 3929
3758 sp.AdjustKnownSeeds(); 3930 sp.AdjustKnownSeeds();
3759 3931
3760 if (CapsModule != null) 3932 if (CapsModule != null)
3761 CapsModule.SetAgentCapsSeeds(agent); 3933 CapsModule.SetAgentCapsSeeds(agent);
3762 } 3934 }
@@ -3858,6 +4030,8 @@ namespace OpenSim.Region.Framework.Scenes
3858 } 4030 }
3859 4031
3860 // Honor parcel landing type and position. 4032 // Honor parcel landing type and position.
4033 /*
4034 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3861 if (land != null) 4035 if (land != null)
3862 { 4036 {
3863 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 4037 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3865,25 +4039,43 @@ namespace OpenSim.Region.Framework.Scenes
3865 agent.startpos = land.LandData.UserLocation; 4039 agent.startpos = land.LandData.UserLocation;
3866 } 4040 }
3867 } 4041 }
4042 */// This is now handled properly in ScenePresence.MakeRootAgent
3868 } 4043 }
3869 4044
3870 return true; 4045 return true;
3871 } 4046 }
3872 4047
3873 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 4048 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3874 { 4049 {
3875 bool banned = land.IsBannedFromLand(agent.AgentID); 4050 if (posX < 0)
3876 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 4051 posX = 0;
4052 else if (posX >= 256)
4053 posX = 255.999f;
4054 if (posY < 0)
4055 posY = 0;
4056 else if (posY >= 256)
4057 posY = 255.999f;
4058
4059 reason = String.Empty;
4060 if (Permissions.IsGod(agentID))
4061 return true;
4062
4063 ILandObject land = LandChannel.GetLandObject(posX, posY);
4064 if (land == null)
4065 return false;
4066
4067 bool banned = land.IsBannedFromLand(agentID);
4068 bool restricted = land.IsRestrictedFromLand(agentID);
3877 4069
3878 if (banned || restricted) 4070 if (banned || restricted)
3879 { 4071 {
3880 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 4072 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3881 if (nearestParcel != null) 4073 if (nearestParcel != null)
3882 { 4074 {
3883 //Move agent to nearest allowed 4075 //Move agent to nearest allowed
3884 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 4076 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3885 agent.startpos.X = newPosition.X; 4077 posX = newPosition.X;
3886 agent.startpos.Y = newPosition.Y; 4078 posY = newPosition.Y;
3887 } 4079 }
3888 else 4080 else
3889 { 4081 {
@@ -3945,7 +4137,7 @@ namespace OpenSim.Region.Framework.Scenes
3945 4137
3946 if (!m_strictAccessControl) return true; 4138 if (!m_strictAccessControl) return true;
3947 if (Permissions.IsGod(agent.AgentID)) return true; 4139 if (Permissions.IsGod(agent.AgentID)) return true;
3948 4140
3949 if (AuthorizationService != null) 4141 if (AuthorizationService != null)
3950 { 4142 {
3951 if (!AuthorizationService.IsAuthorizedForRegion( 4143 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3960,7 +4152,7 @@ namespace OpenSim.Region.Framework.Scenes
3960 4152
3961 if (RegionInfo.EstateSettings != null) 4153 if (RegionInfo.EstateSettings != null)
3962 { 4154 {
3963 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4155 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3964 { 4156 {
3965 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4157 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3966 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4158 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4150,6 +4342,15 @@ namespace OpenSim.Region.Framework.Scenes
4150 4342
4151 // XPTO: if this agent is not allowed here as root, always return false 4343 // XPTO: if this agent is not allowed here as root, always return false
4152 4344
4345 // We have to wait until the viewer contacts this region after receiving EAC.
4346 // That calls AddNewClient, which finally creates the ScenePresence
4347 int flags = GetUserFlags(cAgentData.AgentID);
4348 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4349 {
4350 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4351 return false;
4352 }
4353
4153 // TODO: This check should probably be in QueryAccess(). 4354 // TODO: This check should probably be in QueryAccess().
4154 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4355 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4155 if (nearestParcel == null) 4356 if (nearestParcel == null)
@@ -4214,7 +4415,7 @@ namespace OpenSim.Region.Framework.Scenes
4214 /// <param name='agentID'></param> 4415 /// <param name='agentID'></param>
4215 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4416 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4216 { 4417 {
4217 int ntimes = 10; 4418 int ntimes = 30;
4218 ScenePresence sp = null; 4419 ScenePresence sp = null;
4219 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4420 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4220 Thread.Sleep(1000); 4421 Thread.Sleep(1000);
@@ -4244,6 +4445,16 @@ namespace OpenSim.Region.Framework.Scenes
4244 return false; 4445 return false;
4245 } 4446 }
4246 4447
4448 public bool IncomingCloseAgent(UUID agentID)
4449 {
4450 return IncomingCloseAgent(agentID, false);
4451 }
4452
4453 public bool IncomingCloseChildAgent(UUID agentID)
4454 {
4455 return IncomingCloseAgent(agentID, true);
4456 }
4457
4247 /// <summary> 4458 /// <summary>
4248 /// Tell a single agent to disconnect from the region. 4459 /// Tell a single agent to disconnect from the region.
4249 /// </summary> 4460 /// </summary>
@@ -4259,7 +4470,7 @@ namespace OpenSim.Region.Framework.Scenes
4259 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4470 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4260 if (presence != null) 4471 if (presence != null)
4261 { 4472 {
4262 presence.ControllingClient.Close(force); 4473 presence.ControllingClient.Close(force, force);
4263 return true; 4474 return true;
4264 } 4475 }
4265 4476
@@ -4919,35 +5130,81 @@ namespace OpenSim.Region.Framework.Scenes
4919 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5130 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4920 } 5131 }
4921 5132
4922 public int GetHealth() 5133 public int GetHealth(out int flags, out string message)
4923 { 5134 {
4924 // Returns: 5135 // Returns:
4925 // 1 = sim is up and accepting http requests. The heartbeat has 5136 // 1 = sim is up and accepting http requests. The heartbeat has
4926 // stopped and the sim is probably locked up, but a remote 5137 // stopped and the sim is probably locked up, but a remote
4927 // admin restart may succeed 5138 // admin restart may succeed
4928 // 5139 //
4929 // 2 = Sim is up and the heartbeat is running. The sim is likely 5140 // 2 = Sim is up and the heartbeat is running. The sim is likely
4930 // usable for people within and logins _may_ work 5141 // usable for people within
4931 // 5142 //
4932 // 3 = We have seen a new user enter within the past 4 minutes 5143 // 3 = Sim is up and one packet thread is running. Sim is
5144 // unstable and will not accept new logins
5145 //
5146 // 4 = Sim is up and both packet threads are running. Sim is
5147 // likely usable
5148 //
5149 // 5 = We have seen a new user enter within the past 4 minutes
4933 // which can be seen as positive confirmation of sim health 5150 // which can be seen as positive confirmation of sim health
4934 // 5151 //
5152
5153 flags = 0;
5154 message = String.Empty;
5155
5156 CheckHeartbeat();
5157
5158 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5159 {
5160 // We're still starting
5161 // 0 means "in startup", it can't happen another way, since
5162 // to get here, we must be able to accept http connections
5163 return 0;
5164 }
5165
4935 int health=1; // Start at 1, means we're up 5166 int health=1; // Start at 1, means we're up
4936 5167
4937 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5168 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4938 health += 1; 5169 {
5170 health+=1;
5171 flags |= 1;
5172 }
5173
5174 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5175 {
5176 health+=1;
5177 flags |= 2;
5178 }
5179
5180 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5181 {
5182 health+=1;
5183 flags |= 4;
5184 }
4939 else 5185 else
5186 {
5187int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5188System.Diagnostics.Process proc = new System.Diagnostics.Process();
5189proc.EnableRaisingEvents=false;
5190proc.StartInfo.FileName = "/bin/kill";
5191proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5192proc.Start();
5193proc.WaitForExit();
5194Thread.Sleep(1000);
5195Environment.Exit(1);
5196 }
5197
5198 if (flags != 7)
4940 return health; 5199 return health;
4941 5200
4942 // A login in the last 4 mins? We can't be doing too badly 5201 // A login in the last 4 mins? We can't be doing too badly
4943 // 5202 //
4944 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5203 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4945 health++; 5204 health++;
4946 else 5205 else
4947 return health; 5206 return health;
4948 5207
4949// CheckHeartbeat();
4950
4951 return health; 5208 return health;
4952 } 5209 }
4953 5210
@@ -5035,7 +5292,7 @@ namespace OpenSim.Region.Framework.Scenes
5035 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5292 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5036 if (wasUsingPhysics) 5293 if (wasUsingPhysics)
5037 { 5294 {
5038 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 5295 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
5039 } 5296 }
5040 } 5297 }
5041 5298
@@ -5134,14 +5391,14 @@ namespace OpenSim.Region.Framework.Scenes
5134 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5391 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5135 } 5392 }
5136 5393
5137// private void CheckHeartbeat() 5394 private void CheckHeartbeat()
5138// { 5395 {
5139// if (m_firstHeartbeat) 5396 if (m_firstHeartbeat)
5140// return; 5397 return;
5141// 5398
5142// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5399 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5143// StartTimer(); 5400 Start();
5144// } 5401 }
5145 5402
5146 public override ISceneObject DeserializeObject(string representation) 5403 public override ISceneObject DeserializeObject(string representation)
5147 { 5404 {
@@ -5153,9 +5410,14 @@ namespace OpenSim.Region.Framework.Scenes
5153 get { return m_allowScriptCrossings; } 5410 get { return m_allowScriptCrossings; }
5154 } 5411 }
5155 5412
5156 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5413 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5157 { 5414 {
5158 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5415 return GetNearestAllowedPosition(avatar, null);
5416 }
5417
5418 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5419 {
5420 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
5159 5421
5160 if (nearestParcel != null) 5422 if (nearestParcel != null)
5161 { 5423 {
@@ -5164,10 +5426,7 @@ namespace OpenSim.Region.Framework.Scenes
5164 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5426 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5165 if (nearestPoint != null) 5427 if (nearestPoint != null)
5166 { 5428 {
5167// m_log.DebugFormat( 5429 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
5168// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
5169// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
5170
5171 return nearestPoint.Value; 5430 return nearestPoint.Value;
5172 } 5431 }
5173 5432
@@ -5177,17 +5436,20 @@ namespace OpenSim.Region.Framework.Scenes
5177 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5436 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5178 if (nearestPoint != null) 5437 if (nearestPoint != null)
5179 { 5438 {
5180// m_log.DebugFormat( 5439 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5181// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
5182
5183 return nearestPoint.Value; 5440 return nearestPoint.Value;
5184 } 5441 }
5185 5442
5186 //Ultimate backup if we have no idea where they are 5443 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5187// m_log.DebugFormat( 5444 if (dest != excludeParcel)
5188// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5445 {
5446 // Ultimate backup if we have no idea where they are and
5447 // the last allowed position was in another parcel
5448 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5449 return avatar.lastKnownAllowedPosition;
5450 }
5189 5451
5190 return avatar.lastKnownAllowedPosition; 5452 // else fall through to region edge
5191 } 5453 }
5192 5454
5193 //Go to the edge, this happens in teleporting to a region with no available parcels 5455 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -5221,13 +5483,18 @@ namespace OpenSim.Region.Framework.Scenes
5221 5483
5222 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5484 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5223 { 5485 {
5486 return GetNearestAllowedParcel(avatarId, x, y, null);
5487 }
5488
5489 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5490 {
5224 List<ILandObject> all = AllParcels(); 5491 List<ILandObject> all = AllParcels();
5225 float minParcelDistance = float.MaxValue; 5492 float minParcelDistance = float.MaxValue;
5226 ILandObject nearestParcel = null; 5493 ILandObject nearestParcel = null;
5227 5494
5228 foreach (var parcel in all) 5495 foreach (var parcel in all)
5229 { 5496 {
5230 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5497 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5231 { 5498 {
5232 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5499 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5233 if (parcelDistance < minParcelDistance) 5500 if (parcelDistance < minParcelDistance)
@@ -5469,7 +5736,55 @@ namespace OpenSim.Region.Framework.Scenes
5469 mapModule.GenerateMaptile(); 5736 mapModule.GenerateMaptile();
5470 } 5737 }
5471 5738
5472 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5739// public void CleanDroppedAttachments()
5740// {
5741// List<SceneObjectGroup> objectsToDelete =
5742// new List<SceneObjectGroup>();
5743//
5744// lock (m_cleaningAttachments)
5745// {
5746// ForEachSOG(delegate (SceneObjectGroup grp)
5747// {
5748// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5749// {
5750// UUID agentID = grp.OwnerID;
5751// if (agentID == UUID.Zero)
5752// {
5753// objectsToDelete.Add(grp);
5754// return;
5755// }
5756//
5757// ScenePresence sp = GetScenePresence(agentID);
5758// if (sp == null)
5759// {
5760// objectsToDelete.Add(grp);
5761// return;
5762// }
5763// }
5764// });
5765// }
5766//
5767// foreach (SceneObjectGroup grp in objectsToDelete)
5768// {
5769// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5770// DeleteSceneObject(grp, true);
5771// }
5772// }
5773
5774 public void ThreadAlive(int threadCode)
5775 {
5776 switch(threadCode)
5777 {
5778 case 1: // Incoming
5779 m_lastIncoming = Util.EnvironmentTickCount();
5780 break;
5781 case 2: // Incoming
5782 m_lastOutgoing = Util.EnvironmentTickCount();
5783 break;
5784 }
5785 }
5786
5787 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5473 { 5788 {
5474 RegenerateMaptile(); 5789 RegenerateMaptile();
5475 5790
@@ -5497,6 +5812,8 @@ namespace OpenSim.Region.Framework.Scenes
5497 /// <returns></returns> 5812 /// <returns></returns>
5498 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5813 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5499 { 5814 {
5815 reason = "You are banned from the region";
5816
5500 if (EntityTransferModule.IsInTransit(agentID)) 5817 if (EntityTransferModule.IsInTransit(agentID))
5501 { 5818 {
5502 reason = "Agent is still in transit from this region"; 5819 reason = "Agent is still in transit from this region";
@@ -5508,6 +5825,12 @@ namespace OpenSim.Region.Framework.Scenes
5508 return false; 5825 return false;
5509 } 5826 }
5510 5827
5828 if (Permissions.IsGod(agentID))
5829 {
5830 reason = String.Empty;
5831 return true;
5832 }
5833
5511 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5834 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5512 // However, the long term fix is to make sure root agent count is always accurate. 5835 // However, the long term fix is to make sure root agent count is always accurate.
5513 m_sceneGraph.RecalculateStats(); 5836 m_sceneGraph.RecalculateStats();
@@ -5528,6 +5851,41 @@ namespace OpenSim.Region.Framework.Scenes
5528 } 5851 }
5529 } 5852 }
5530 5853
5854 ScenePresence presence = GetScenePresence(agentID);
5855 IClientAPI client = null;
5856 AgentCircuitData aCircuit = null;
5857
5858 if (presence != null)
5859 {
5860 client = presence.ControllingClient;
5861 if (client != null)
5862 aCircuit = client.RequestClientInfo();
5863 }
5864
5865 // We may be called before there is a presence or a client.
5866 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5867 if (client == null)
5868 {
5869 aCircuit = new AgentCircuitData();
5870 aCircuit.AgentID = agentID;
5871 aCircuit.firstname = String.Empty;
5872 aCircuit.lastname = String.Empty;
5873 }
5874
5875 try
5876 {
5877 if (!AuthorizeUser(aCircuit, out reason))
5878 {
5879 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5880 return false;
5881 }
5882 }
5883 catch (Exception e)
5884 {
5885 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5886 return false;
5887 }
5888
5531 if (position == Vector3.Zero) // Teleport 5889 if (position == Vector3.Zero) // Teleport
5532 { 5890 {
5533 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5891 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5556,13 +5914,46 @@ namespace OpenSim.Region.Framework.Scenes
5556 } 5914 }
5557 } 5915 }
5558 } 5916 }
5917
5918 float posX = 128.0f;
5919 float posY = 128.0f;
5920
5921 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5922 {
5923 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5924 return false;
5925 }
5926 }
5927 else // Walking
5928 {
5929 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5930 if (land == null)
5931 return false;
5932
5933 bool banned = land.IsBannedFromLand(agentID);
5934 bool restricted = land.IsRestrictedFromLand(agentID);
5935
5936 if (banned || restricted)
5937 return false;
5559 } 5938 }
5560 5939
5561 reason = String.Empty; 5940 reason = String.Empty;
5562 return true; 5941 return true;
5563 } 5942 }
5564 5943
5565 /// <summary> 5944 public void StartTimerWatchdog()
5945 {
5946 m_timerWatchdog.Interval = 1000;
5947 m_timerWatchdog.Elapsed += TimerWatchdog;
5948 m_timerWatchdog.AutoReset = true;
5949 m_timerWatchdog.Start();
5950 }
5951
5952 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5953 {
5954 CheckHeartbeat();
5955 }
5956
5566 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5957 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5567 /// autopilot that moves an avatar to a sit target!. 5958 /// autopilot that moves an avatar to a sit target!.
5568 /// </summary> 5959 /// </summary>
@@ -5641,6 +6032,11 @@ namespace OpenSim.Region.Framework.Scenes
5641 return m_SpawnPoint - 1; 6032 return m_SpawnPoint - 1;
5642 } 6033 }
5643 6034
6035 private void HandleGcCollect(string module, string[] args)
6036 {
6037 GC.Collect();
6038 }
6039
5644 // Wrappers to get physics modules retrieve assets. Has to be done this way 6040 // Wrappers to get physics modules retrieve assets. Has to be done this way
5645 // because we can't assign the asset service to physics directly - at the 6041 // because we can't assign the asset service to physics directly - at the
5646 // time physics are instantiated it's not registered but it will be by 6042 // time physics are instantiated it's not registered but it will be by