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.cs862
1 files changed, 629 insertions, 233 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 9c61fe7..218d4e4 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
@@ -1692,9 +1748,9 @@ namespace OpenSim.Region.Framework.Scenes
1692 1748
1693 private void CheckAtTargets() 1749 private void CheckAtTargets()
1694 { 1750 {
1695 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1751 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1696 lock (m_groupsWithTargets) 1752 lock (m_groupsWithTargets)
1697 objs = m_groupsWithTargets.Values; 1753 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1698 1754
1699 foreach (SceneObjectGroup entry in objs) 1755 foreach (SceneObjectGroup entry in objs)
1700 entry.checkAtTargets(); 1756 entry.checkAtTargets();
@@ -1775,7 +1831,7 @@ namespace OpenSim.Region.Framework.Scenes
1775 msg.fromAgentName = "Server"; 1831 msg.fromAgentName = "Server";
1776 msg.dialog = (byte)19; // Object msg 1832 msg.dialog = (byte)19; // Object msg
1777 msg.fromGroup = false; 1833 msg.fromGroup = false;
1778 msg.offline = (byte)0; 1834 msg.offline = (byte)1;
1779 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1835 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1780 msg.Position = Vector3.Zero; 1836 msg.Position = Vector3.Zero;
1781 msg.RegionID = RegionInfo.RegionID.Guid; 1837 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1997,6 +2053,19 @@ namespace OpenSim.Region.Framework.Scenes
1997 EventManager.TriggerPrimsLoaded(this); 2053 EventManager.TriggerPrimsLoaded(this);
1998 } 2054 }
1999 2055
2056 public bool SuportsRayCastFiltered()
2057 {
2058 if (PhysicsScene == null)
2059 return false;
2060 return PhysicsScene.SuportsRaycastWorldFiltered();
2061 }
2062
2063 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2064 {
2065 if (PhysicsScene == null)
2066 return null;
2067 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
2068 }
2000 2069
2001 /// <summary> 2070 /// <summary>
2002 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 2071 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -2013,14 +2082,24 @@ namespace OpenSim.Region.Framework.Scenes
2013 /// <returns></returns> 2082 /// <returns></returns>
2014 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2083 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
2015 { 2084 {
2085
2086 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2087 Vector3 wpos = Vector3.Zero;
2088 // Check for water surface intersection from above
2089 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2090 {
2091 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2092 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2093 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2094 wpos.Z = wheight;
2095 }
2096
2016 Vector3 pos = Vector3.Zero; 2097 Vector3 pos = Vector3.Zero;
2017 if (RayEndIsIntersection == (byte)1) 2098 if (RayEndIsIntersection == (byte)1)
2018 { 2099 {
2019 pos = RayEnd; 2100 pos = RayEnd;
2020 return pos;
2021 } 2101 }
2022 2102 else if (RayTargetID != UUID.Zero)
2023 if (RayTargetID != UUID.Zero)
2024 { 2103 {
2025 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2104 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
2026 2105
@@ -2042,7 +2121,7 @@ namespace OpenSim.Region.Framework.Scenes
2042 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2121 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2043 2122
2044 // Un-comment out the following line to Get Raytrace results printed to the console. 2123 // Un-comment out the following line to Get Raytrace results printed to the console.
2045 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2124 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2046 float ScaleOffset = 0.5f; 2125 float ScaleOffset = 0.5f;
2047 2126
2048 // If we hit something 2127 // If we hit something
@@ -2065,13 +2144,10 @@ namespace OpenSim.Region.Framework.Scenes
2065 //pos.Z -= 0.25F; 2144 //pos.Z -= 0.25F;
2066 2145
2067 } 2146 }
2068
2069 return pos;
2070 } 2147 }
2071 else 2148 else
2072 { 2149 {
2073 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2150 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2074
2075 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2151 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2076 2152
2077 // Un-comment the following line to print the raytrace results to the console. 2153 // Un-comment the following line to print the raytrace results to the console.
@@ -2080,13 +2156,12 @@ namespace OpenSim.Region.Framework.Scenes
2080 if (ei.HitTF) 2156 if (ei.HitTF)
2081 { 2157 {
2082 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2158 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2083 } else 2159 }
2160 else
2084 { 2161 {
2085 // fall back to our stupid functionality 2162 // fall back to our stupid functionality
2086 pos = RayEnd; 2163 pos = RayEnd;
2087 } 2164 }
2088
2089 return pos;
2090 } 2165 }
2091 } 2166 }
2092 else 2167 else
@@ -2097,8 +2172,12 @@ namespace OpenSim.Region.Framework.Scenes
2097 //increase height so its above the ground. 2172 //increase height so its above the ground.
2098 //should be getting the normal of the ground at the rez point and using that? 2173 //should be getting the normal of the ground at the rez point and using that?
2099 pos.Z += scale.Z / 2f; 2174 pos.Z += scale.Z / 2f;
2100 return pos; 2175// return pos;
2101 } 2176 }
2177
2178 // check against posible water intercept
2179 if (wpos.Z > pos.Z) pos = wpos;
2180 return pos;
2102 } 2181 }
2103 2182
2104 2183
@@ -2189,12 +2268,12 @@ namespace OpenSim.Region.Framework.Scenes
2189 { 2268 {
2190 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) 2269 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2191 { 2270 {
2271 sceneObject.IsDeleted = false;
2192 EventManager.TriggerObjectAddedToScene(sceneObject); 2272 EventManager.TriggerObjectAddedToScene(sceneObject);
2193 return true; 2273 return true;
2194 } 2274 }
2195 2275
2196 return false; 2276 return false;
2197
2198 } 2277 }
2199 2278
2200 /// <summary> 2279 /// <summary>
@@ -2286,6 +2365,15 @@ namespace OpenSim.Region.Framework.Scenes
2286 /// </summary> 2365 /// </summary>
2287 public void DeleteAllSceneObjects() 2366 public void DeleteAllSceneObjects()
2288 { 2367 {
2368 DeleteAllSceneObjects(false);
2369 }
2370
2371 /// <summary>
2372 /// Delete every object from the scene. This does not include attachments worn by avatars.
2373 /// </summary>
2374 public void DeleteAllSceneObjects(bool exceptNoCopy)
2375 {
2376 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2289 lock (Entities) 2377 lock (Entities)
2290 { 2378 {
2291 EntityBase[] entities = Entities.GetEntities(); 2379 EntityBase[] entities = Entities.GetEntities();
@@ -2294,11 +2382,24 @@ namespace OpenSim.Region.Framework.Scenes
2294 if (e is SceneObjectGroup) 2382 if (e is SceneObjectGroup)
2295 { 2383 {
2296 SceneObjectGroup sog = (SceneObjectGroup)e; 2384 SceneObjectGroup sog = (SceneObjectGroup)e;
2297 if (!sog.IsAttachment) 2385 if (sog != null && !sog.IsAttachment)
2298 DeleteSceneObject((SceneObjectGroup)e, false); 2386 {
2387 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2388 {
2389 DeleteSceneObject((SceneObjectGroup)e, false);
2390 }
2391 else
2392 {
2393 toReturn.Add((SceneObjectGroup)e);
2394 }
2395 }
2299 } 2396 }
2300 } 2397 }
2301 } 2398 }
2399 if (toReturn.Count > 0)
2400 {
2401 returnObjects(toReturn.ToArray(), UUID.Zero);
2402 }
2302 } 2403 }
2303 2404
2304 /// <summary> 2405 /// <summary>
@@ -2333,6 +2434,12 @@ namespace OpenSim.Region.Framework.Scenes
2333 2434
2334 foreach (SceneObjectPart part in partList) 2435 foreach (SceneObjectPart part in partList)
2335 { 2436 {
2437 if (part.KeyframeMotion != null)
2438 {
2439 part.KeyframeMotion.Delete();
2440 part.KeyframeMotion = null;
2441 }
2442
2336 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) 2443 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
2337 { 2444 {
2338 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? 2445 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
@@ -2350,6 +2457,8 @@ namespace OpenSim.Region.Framework.Scenes
2350 } 2457 }
2351 2458
2352 group.DeleteGroupFromScene(silent); 2459 group.DeleteGroupFromScene(silent);
2460 if (!silent)
2461 SendKillObject(new List<uint>() { group.LocalId });
2353 2462
2354// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2463// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2355 } 2464 }
@@ -2640,7 +2749,7 @@ namespace OpenSim.Region.Framework.Scenes
2640 // If the user is banned, we won't let any of their objects 2749 // If the user is banned, we won't let any of their objects
2641 // enter. Period. 2750 // enter. Period.
2642 // 2751 //
2643 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2752 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2644 { 2753 {
2645 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2754 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2646 return false; 2755 return false;
@@ -2648,6 +2757,8 @@ namespace OpenSim.Region.Framework.Scenes
2648 2757
2649 if (newPosition != Vector3.Zero) 2758 if (newPosition != Vector3.Zero)
2650 newObject.RootPart.GroupPosition = newPosition; 2759 newObject.RootPart.GroupPosition = newPosition;
2760 if (newObject.RootPart.KeyframeMotion != null)
2761 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2651 2762
2652 if (!AddSceneObject(newObject)) 2763 if (!AddSceneObject(newObject))
2653 { 2764 {
@@ -2692,6 +2803,23 @@ namespace OpenSim.Region.Framework.Scenes
2692 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2803 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2693 public bool AddSceneObject(SceneObjectGroup sceneObject) 2804 public bool AddSceneObject(SceneObjectGroup sceneObject)
2694 { 2805 {
2806 if (sceneObject.OwnerID == UUID.Zero)
2807 {
2808 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2809 return false;
2810 }
2811
2812 // If the user is banned, we won't let any of their objects
2813 // enter. Period.
2814 //
2815 int flags = GetUserFlags(sceneObject.OwnerID);
2816 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2817 {
2818 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2819
2820 return false;
2821 }
2822
2695 // Force allocation of new LocalId 2823 // Force allocation of new LocalId
2696 // 2824 //
2697 SceneObjectPart[] parts = sceneObject.Parts; 2825 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2725,16 +2853,27 @@ namespace OpenSim.Region.Framework.Scenes
2725 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2853 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2726 2854
2727 if (AttachmentsModule != null) 2855 if (AttachmentsModule != null)
2728 AttachmentsModule.AttachObject(sp, grp, 0, false, false); 2856 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false);
2729 } 2857 }
2730 else 2858 else
2731 { 2859 {
2860 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2732 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2861 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2733 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2862 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2734 } 2863 }
2864 if (sceneObject.OwnerID == UUID.Zero)
2865 {
2866 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2867 return false;
2868 }
2735 } 2869 }
2736 else 2870 else
2737 { 2871 {
2872 if (sceneObject.OwnerID == UUID.Zero)
2873 {
2874 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2875 return false;
2876 }
2738 AddRestoredSceneObject(sceneObject, true, false); 2877 AddRestoredSceneObject(sceneObject, true, false);
2739 } 2878 }
2740 2879
@@ -2751,6 +2890,24 @@ namespace OpenSim.Region.Framework.Scenes
2751 return 2; // StateSource.PrimCrossing 2890 return 2; // StateSource.PrimCrossing
2752 } 2891 }
2753 2892
2893 public int GetUserFlags(UUID user)
2894 {
2895 //Unfortunately the SP approach means that the value is cached until region is restarted
2896 /*
2897 ScenePresence sp;
2898 if (TryGetScenePresence(user, out sp))
2899 {
2900 return sp.UserFlags;
2901 }
2902 else
2903 {
2904 */
2905 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2906 if (uac == null)
2907 return 0;
2908 return uac.UserFlags;
2909 //}
2910 }
2754 #endregion 2911 #endregion
2755 2912
2756 #region Add/Remove Avatar Methods 2913 #region Add/Remove Avatar Methods
@@ -2783,7 +2940,7 @@ namespace OpenSim.Region.Framework.Scenes
2783 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2940 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2784 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2941 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2785 2942
2786 // CheckHeartbeat(); 2943 CheckHeartbeat();
2787 2944
2788 sp = GetScenePresence(client.AgentId); 2945 sp = GetScenePresence(client.AgentId);
2789 2946
@@ -2927,19 +3084,14 @@ namespace OpenSim.Region.Framework.Scenes
2927 // and the scene presence and the client, if they exist 3084 // and the scene presence and the client, if they exist
2928 try 3085 try
2929 { 3086 {
2930 // We need to wait for the client to make UDP contact first. 3087 ScenePresence sp = GetScenePresence(agentID);
2931 // It's the UDP contact that creates the scene presence 3088
2932 ScenePresence sp = WaitGetScenePresence(agentID);
2933 if (sp != null) 3089 if (sp != null)
2934 { 3090 {
2935 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3091 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2936
2937 sp.ControllingClient.Close(); 3092 sp.ControllingClient.Close();
2938 } 3093 }
2939 else 3094
2940 {
2941 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2942 }
2943 // BANG! SLASH! 3095 // BANG! SLASH!
2944 m_authenticateHandler.RemoveCircuit(agentID); 3096 m_authenticateHandler.RemoveCircuit(agentID);
2945 3097
@@ -2984,6 +3136,8 @@ namespace OpenSim.Region.Framework.Scenes
2984 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3136 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2985 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3137 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2986 3138
3139 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3140
2987 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3141 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2988 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3142 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2989 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3143 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -3040,6 +3194,7 @@ namespace OpenSim.Region.Framework.Scenes
3040 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3194 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
3041 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3195 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
3042 client.OnCopyInventoryItem += CopyInventoryItem; 3196 client.OnCopyInventoryItem += CopyInventoryItem;
3197 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
3043 client.OnMoveInventoryItem += MoveInventoryItem; 3198 client.OnMoveInventoryItem += MoveInventoryItem;
3044 client.OnRemoveInventoryItem += RemoveInventoryItem; 3199 client.OnRemoveInventoryItem += RemoveInventoryItem;
3045 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3200 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3111,6 +3266,8 @@ namespace OpenSim.Region.Framework.Scenes
3111 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3266 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3112 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3267 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3113 3268
3269 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3270
3114 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3271 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3115 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3272 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3116 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3273 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3213,7 +3370,7 @@ namespace OpenSim.Region.Framework.Scenes
3213 /// </summary> 3370 /// </summary>
3214 /// <param name="agentId">The avatar's Unique ID</param> 3371 /// <param name="agentId">The avatar's Unique ID</param>
3215 /// <param name="client">The IClientAPI for the client</param> 3372 /// <param name="client">The IClientAPI for the client</param>
3216 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3373 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3217 { 3374 {
3218 if (EntityTransferModule != null) 3375 if (EntityTransferModule != null)
3219 { 3376 {
@@ -3224,6 +3381,7 @@ namespace OpenSim.Region.Framework.Scenes
3224 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3381 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3225 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3382 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3226 } 3383 }
3384 return false;
3227 } 3385 }
3228 3386
3229 /// <summary> 3387 /// <summary>
@@ -3333,6 +3491,16 @@ namespace OpenSim.Region.Framework.Scenes
3333 /// <param name="flags"></param> 3491 /// <param name="flags"></param>
3334 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3492 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3335 { 3493 {
3494 //Add half the avatar's height so that the user doesn't fall through prims
3495 ScenePresence presence;
3496 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3497 {
3498 if (presence.Appearance != null)
3499 {
3500 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3501 }
3502 }
3503
3336 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3504 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3337 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3505 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3338 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3506 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3469,6 +3637,7 @@ namespace OpenSim.Region.Framework.Scenes
3469 // It's possible for child agents to have transactions if changes are being made cross-border. 3637 // It's possible for child agents to have transactions if changes are being made cross-border.
3470 if (AgentTransactionsModule != null) 3638 if (AgentTransactionsModule != null)
3471 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3639 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3640 m_log.Debug("[Scene] The avatar has left the building");
3472 } 3641 }
3473 catch (Exception e) 3642 catch (Exception e)
3474 { 3643 {
@@ -3661,38 +3830,39 @@ namespace OpenSim.Region.Framework.Scenes
3661 agent.firstname, agent.lastname, agent.Viewer); 3830 agent.firstname, agent.lastname, agent.Viewer);
3662 reason = "Access denied, your viewer is banned by the region owner"; 3831 reason = "Access denied, your viewer is banned by the region owner";
3663 return false; 3832 return false;
3664 } 3833 }
3834
3665 3835
3666 ILandObject land; 3836 ScenePresence sp = GetScenePresence(agent.AgentID);
3837
3838 if (sp != null && !sp.IsChildAgent)
3839 {
3840 // We have a zombie from a crashed session.
3841 // Or the same user is trying to be root twice here, won't work.
3842 // Kill it.
3843 m_log.WarnFormat(
3844 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3845 sp.Name, sp.UUID, RegionInfo.RegionName);
3846
3847 sp.ControllingClient.Close(true, true);
3848 sp = null;
3849 }
3667 3850
3668 lock (agent) 3851 lock (agent)
3669 { 3852 {
3670 ScenePresence sp = GetScenePresence(agent.AgentID);
3671
3672 if (sp != null && !sp.IsChildAgent)
3673 {
3674 // We have a zombie from a crashed session.
3675 // Or the same user is trying to be root twice here, won't work.
3676 // Kill it.
3677 m_log.WarnFormat(
3678 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3679 sp.Name, sp.UUID, RegionInfo.RegionName);
3680
3681 sp.ControllingClient.Close(true);
3682 sp = null;
3683 }
3684
3685 land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3686
3687 //On login test land permisions 3853 //On login test land permisions
3688 if (vialogin) 3854 if (vialogin)
3689 { 3855 {
3690 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3856 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3857 if (cache != null)
3858 cache.Remove(agent.firstname + " " + agent.lastname);
3859 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3691 { 3860 {
3861 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3692 return false; 3862 return false;
3693 } 3863 }
3694 } 3864 }
3695 3865
3696 if (sp == null) // We don't have an [child] agent here already 3866 if (sp == null) // We don't have an [child] agent here already
3697 { 3867 {
3698 if (requirePresenceLookup) 3868 if (requirePresenceLookup)
@@ -3701,34 +3871,36 @@ namespace OpenSim.Region.Framework.Scenes
3701 { 3871 {
3702 if (!VerifyUserPresence(agent, out reason)) 3872 if (!VerifyUserPresence(agent, out reason))
3703 return false; 3873 return false;
3704 } 3874 } catch (Exception e)
3705 catch (Exception e)
3706 { 3875 {
3707 m_log.ErrorFormat( 3876 m_log.ErrorFormat(
3708 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3877 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
3709
3710 return false; 3878 return false;
3711 } 3879 }
3712 } 3880 }
3713 3881
3714 try 3882 try
3715 { 3883 {
3716 if (!AuthorizeUser(agent, out reason)) 3884 // Always check estate if this is a login. Always
3717 return false; 3885 // check if banned regions are to be blacked out.
3886 if (vialogin || (!m_seeIntoBannedRegion))
3887 {
3888 if (!AuthorizeUser(agent, out reason))
3889 return false;
3890 }
3718 } 3891 }
3719 catch (Exception e) 3892 catch (Exception e)
3720 { 3893 {
3721 m_log.ErrorFormat( 3894 m_log.ErrorFormat(
3722 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3895 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
3723
3724 return false; 3896 return false;
3725 } 3897 }
3726 3898
3727 m_log.InfoFormat( 3899 m_log.InfoFormat(
3728 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 3900 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3729 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3901 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3730 agent.AgentID, agent.circuitcode); 3902 agent.AgentID, agent.circuitcode);
3731 3903
3732 if (CapsModule != null) 3904 if (CapsModule != null)
3733 { 3905 {
3734 CapsModule.SetAgentCapsSeeds(agent); 3906 CapsModule.SetAgentCapsSeeds(agent);
@@ -3740,15 +3912,15 @@ namespace OpenSim.Region.Framework.Scenes
3740 // Let the SP know how we got here. This has a lot of interesting 3912 // Let the SP know how we got here. This has a lot of interesting
3741 // uses down the line. 3913 // uses down the line.
3742 sp.TeleportFlags = (TPFlags)teleportFlags; 3914 sp.TeleportFlags = (TPFlags)teleportFlags;
3743 3915
3744 if (sp.IsChildAgent) 3916 if (sp.IsChildAgent)
3745 { 3917 {
3746 m_log.DebugFormat( 3918 m_log.DebugFormat(
3747 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", 3919 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
3748 agent.AgentID, RegionInfo.RegionName); 3920 agent.AgentID, RegionInfo.RegionName);
3749 3921
3750 sp.AdjustKnownSeeds(); 3922 sp.AdjustKnownSeeds();
3751 3923
3752 if (CapsModule != null) 3924 if (CapsModule != null)
3753 CapsModule.SetAgentCapsSeeds(agent); 3925 CapsModule.SetAgentCapsSeeds(agent);
3754 } 3926 }
@@ -3850,6 +4022,8 @@ namespace OpenSim.Region.Framework.Scenes
3850 } 4022 }
3851 4023
3852 // Honor parcel landing type and position. 4024 // Honor parcel landing type and position.
4025 /*
4026 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3853 if (land != null) 4027 if (land != null)
3854 { 4028 {
3855 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 4029 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3857,25 +4031,43 @@ namespace OpenSim.Region.Framework.Scenes
3857 agent.startpos = land.LandData.UserLocation; 4031 agent.startpos = land.LandData.UserLocation;
3858 } 4032 }
3859 } 4033 }
4034 */// This is now handled properly in ScenePresence.MakeRootAgent
3860 } 4035 }
3861 4036
3862 return true; 4037 return true;
3863 } 4038 }
3864 4039
3865 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 4040 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3866 { 4041 {
3867 bool banned = land.IsBannedFromLand(agent.AgentID); 4042 if (posX < 0)
3868 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 4043 posX = 0;
4044 else if (posX >= 256)
4045 posX = 255.999f;
4046 if (posY < 0)
4047 posY = 0;
4048 else if (posY >= 256)
4049 posY = 255.999f;
4050
4051 reason = String.Empty;
4052 if (Permissions.IsGod(agentID))
4053 return true;
4054
4055 ILandObject land = LandChannel.GetLandObject(posX, posY);
4056 if (land == null)
4057 return false;
4058
4059 bool banned = land.IsBannedFromLand(agentID);
4060 bool restricted = land.IsRestrictedFromLand(agentID);
3869 4061
3870 if (banned || restricted) 4062 if (banned || restricted)
3871 { 4063 {
3872 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 4064 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3873 if (nearestParcel != null) 4065 if (nearestParcel != null)
3874 { 4066 {
3875 //Move agent to nearest allowed 4067 //Move agent to nearest allowed
3876 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 4068 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3877 agent.startpos.X = newPosition.X; 4069 posX = newPosition.X;
3878 agent.startpos.Y = newPosition.Y; 4070 posY = newPosition.Y;
3879 } 4071 }
3880 else 4072 else
3881 { 4073 {
@@ -3937,7 +4129,7 @@ namespace OpenSim.Region.Framework.Scenes
3937 4129
3938 if (!m_strictAccessControl) return true; 4130 if (!m_strictAccessControl) return true;
3939 if (Permissions.IsGod(agent.AgentID)) return true; 4131 if (Permissions.IsGod(agent.AgentID)) return true;
3940 4132
3941 if (AuthorizationService != null) 4133 if (AuthorizationService != null)
3942 { 4134 {
3943 if (!AuthorizationService.IsAuthorizedForRegion( 4135 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3952,7 +4144,7 @@ namespace OpenSim.Region.Framework.Scenes
3952 4144
3953 if (RegionInfo.EstateSettings != null) 4145 if (RegionInfo.EstateSettings != null)
3954 { 4146 {
3955 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4147 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3956 { 4148 {
3957 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4149 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3958 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4150 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4142,6 +4334,15 @@ namespace OpenSim.Region.Framework.Scenes
4142 4334
4143 // XPTO: if this agent is not allowed here as root, always return false 4335 // XPTO: if this agent is not allowed here as root, always return false
4144 4336
4337 // We have to wait until the viewer contacts this region after receiving EAC.
4338 // That calls AddNewClient, which finally creates the ScenePresence
4339 int flags = GetUserFlags(cAgentData.AgentID);
4340 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4341 {
4342 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4343 return false;
4344 }
4345
4145 // TODO: This check should probably be in QueryAccess(). 4346 // TODO: This check should probably be in QueryAccess().
4146 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4347 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4147 if (nearestParcel == null) 4348 if (nearestParcel == null)
@@ -4206,7 +4407,7 @@ namespace OpenSim.Region.Framework.Scenes
4206 /// <param name='agentID'></param> 4407 /// <param name='agentID'></param>
4207 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4408 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4208 { 4409 {
4209 int ntimes = 10; 4410 int ntimes = 30;
4210 ScenePresence sp = null; 4411 ScenePresence sp = null;
4211 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4412 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4212 Thread.Sleep(1000); 4413 Thread.Sleep(1000);
@@ -4236,6 +4437,16 @@ namespace OpenSim.Region.Framework.Scenes
4236 return false; 4437 return false;
4237 } 4438 }
4238 4439
4440 public bool IncomingCloseAgent(UUID agentID)
4441 {
4442 return IncomingCloseAgent(agentID, false);
4443 }
4444
4445 public bool IncomingCloseChildAgent(UUID agentID)
4446 {
4447 return IncomingCloseAgent(agentID, true);
4448 }
4449
4239 /// <summary> 4450 /// <summary>
4240 /// Tell a single agent to disconnect from the region. 4451 /// Tell a single agent to disconnect from the region.
4241 /// </summary> 4452 /// </summary>
@@ -4251,7 +4462,7 @@ namespace OpenSim.Region.Framework.Scenes
4251 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4462 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4252 if (presence != null) 4463 if (presence != null)
4253 { 4464 {
4254 presence.ControllingClient.Close(force); 4465 presence.ControllingClient.Close(force, force);
4255 return true; 4466 return true;
4256 } 4467 }
4257 4468
@@ -4911,35 +5122,81 @@ namespace OpenSim.Region.Framework.Scenes
4911 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5122 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4912 } 5123 }
4913 5124
4914 public int GetHealth() 5125 public int GetHealth(out int flags, out string message)
4915 { 5126 {
4916 // Returns: 5127 // Returns:
4917 // 1 = sim is up and accepting http requests. The heartbeat has 5128 // 1 = sim is up and accepting http requests. The heartbeat has
4918 // stopped and the sim is probably locked up, but a remote 5129 // stopped and the sim is probably locked up, but a remote
4919 // admin restart may succeed 5130 // admin restart may succeed
4920 // 5131 //
4921 // 2 = Sim is up and the heartbeat is running. The sim is likely 5132 // 2 = Sim is up and the heartbeat is running. The sim is likely
4922 // usable for people within and logins _may_ work 5133 // usable for people within
4923 // 5134 //
4924 // 3 = We have seen a new user enter within the past 4 minutes 5135 // 3 = Sim is up and one packet thread is running. Sim is
5136 // unstable and will not accept new logins
5137 //
5138 // 4 = Sim is up and both packet threads are running. Sim is
5139 // likely usable
5140 //
5141 // 5 = We have seen a new user enter within the past 4 minutes
4925 // which can be seen as positive confirmation of sim health 5142 // which can be seen as positive confirmation of sim health
4926 // 5143 //
5144
5145 flags = 0;
5146 message = String.Empty;
5147
5148 CheckHeartbeat();
5149
5150 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5151 {
5152 // We're still starting
5153 // 0 means "in startup", it can't happen another way, since
5154 // to get here, we must be able to accept http connections
5155 return 0;
5156 }
5157
4927 int health=1; // Start at 1, means we're up 5158 int health=1; // Start at 1, means we're up
4928 5159
4929 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5160 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4930 health += 1; 5161 {
5162 health+=1;
5163 flags |= 1;
5164 }
5165
5166 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5167 {
5168 health+=1;
5169 flags |= 2;
5170 }
5171
5172 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5173 {
5174 health+=1;
5175 flags |= 4;
5176 }
4931 else 5177 else
5178 {
5179int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5180System.Diagnostics.Process proc = new System.Diagnostics.Process();
5181proc.EnableRaisingEvents=false;
5182proc.StartInfo.FileName = "/bin/kill";
5183proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5184proc.Start();
5185proc.WaitForExit();
5186Thread.Sleep(1000);
5187Environment.Exit(1);
5188 }
5189
5190 if (flags != 7)
4932 return health; 5191 return health;
4933 5192
4934 // A login in the last 4 mins? We can't be doing too badly 5193 // A login in the last 4 mins? We can't be doing too badly
4935 // 5194 //
4936 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5195 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4937 health++; 5196 health++;
4938 else 5197 else
4939 return health; 5198 return health;
4940 5199
4941// CheckHeartbeat();
4942
4943 return health; 5200 return health;
4944 } 5201 }
4945 5202
@@ -5027,7 +5284,7 @@ namespace OpenSim.Region.Framework.Scenes
5027 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5284 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5028 if (wasUsingPhysics) 5285 if (wasUsingPhysics)
5029 { 5286 {
5030 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 5287 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
5031 } 5288 }
5032 } 5289 }
5033 5290
@@ -5126,14 +5383,14 @@ namespace OpenSim.Region.Framework.Scenes
5126 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5383 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5127 } 5384 }
5128 5385
5129// private void CheckHeartbeat() 5386 private void CheckHeartbeat()
5130// { 5387 {
5131// if (m_firstHeartbeat) 5388 if (m_firstHeartbeat)
5132// return; 5389 return;
5133// 5390
5134// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5391 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5135// StartTimer(); 5392 Start();
5136// } 5393 }
5137 5394
5138 public override ISceneObject DeserializeObject(string representation) 5395 public override ISceneObject DeserializeObject(string representation)
5139 { 5396 {
@@ -5145,9 +5402,14 @@ namespace OpenSim.Region.Framework.Scenes
5145 get { return m_allowScriptCrossings; } 5402 get { return m_allowScriptCrossings; }
5146 } 5403 }
5147 5404
5148 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5405 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5149 { 5406 {
5150 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5407 return GetNearestAllowedPosition(avatar, null);
5408 }
5409
5410 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5411 {
5412 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
5151 5413
5152 if (nearestParcel != null) 5414 if (nearestParcel != null)
5153 { 5415 {
@@ -5156,10 +5418,7 @@ namespace OpenSim.Region.Framework.Scenes
5156 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5418 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5157 if (nearestPoint != null) 5419 if (nearestPoint != null)
5158 { 5420 {
5159// m_log.DebugFormat( 5421 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
5160// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
5161// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
5162
5163 return nearestPoint.Value; 5422 return nearestPoint.Value;
5164 } 5423 }
5165 5424
@@ -5169,17 +5428,20 @@ namespace OpenSim.Region.Framework.Scenes
5169 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5428 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5170 if (nearestPoint != null) 5429 if (nearestPoint != null)
5171 { 5430 {
5172// m_log.DebugFormat( 5431 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5173// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
5174
5175 return nearestPoint.Value; 5432 return nearestPoint.Value;
5176 } 5433 }
5177 5434
5178 //Ultimate backup if we have no idea where they are 5435 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5179// m_log.DebugFormat( 5436 if (dest != excludeParcel)
5180// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5437 {
5438 // Ultimate backup if we have no idea where they are and
5439 // the last allowed position was in another parcel
5440 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5441 return avatar.lastKnownAllowedPosition;
5442 }
5181 5443
5182 return avatar.lastKnownAllowedPosition; 5444 // else fall through to region edge
5183 } 5445 }
5184 5446
5185 //Go to the edge, this happens in teleporting to a region with no available parcels 5447 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -5213,13 +5475,18 @@ namespace OpenSim.Region.Framework.Scenes
5213 5475
5214 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5476 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5215 { 5477 {
5478 return GetNearestAllowedParcel(avatarId, x, y, null);
5479 }
5480
5481 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5482 {
5216 List<ILandObject> all = AllParcels(); 5483 List<ILandObject> all = AllParcels();
5217 float minParcelDistance = float.MaxValue; 5484 float minParcelDistance = float.MaxValue;
5218 ILandObject nearestParcel = null; 5485 ILandObject nearestParcel = null;
5219 5486
5220 foreach (var parcel in all) 5487 foreach (var parcel in all)
5221 { 5488 {
5222 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5489 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5223 { 5490 {
5224 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5491 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5225 if (parcelDistance < minParcelDistance) 5492 if (parcelDistance < minParcelDistance)
@@ -5461,7 +5728,55 @@ namespace OpenSim.Region.Framework.Scenes
5461 mapModule.GenerateMaptile(); 5728 mapModule.GenerateMaptile();
5462 } 5729 }
5463 5730
5464 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5731// public void CleanDroppedAttachments()
5732// {
5733// List<SceneObjectGroup> objectsToDelete =
5734// new List<SceneObjectGroup>();
5735//
5736// lock (m_cleaningAttachments)
5737// {
5738// ForEachSOG(delegate (SceneObjectGroup grp)
5739// {
5740// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5741// {
5742// UUID agentID = grp.OwnerID;
5743// if (agentID == UUID.Zero)
5744// {
5745// objectsToDelete.Add(grp);
5746// return;
5747// }
5748//
5749// ScenePresence sp = GetScenePresence(agentID);
5750// if (sp == null)
5751// {
5752// objectsToDelete.Add(grp);
5753// return;
5754// }
5755// }
5756// });
5757// }
5758//
5759// foreach (SceneObjectGroup grp in objectsToDelete)
5760// {
5761// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5762// DeleteSceneObject(grp, true);
5763// }
5764// }
5765
5766 public void ThreadAlive(int threadCode)
5767 {
5768 switch(threadCode)
5769 {
5770 case 1: // Incoming
5771 m_lastIncoming = Util.EnvironmentTickCount();
5772 break;
5773 case 2: // Incoming
5774 m_lastOutgoing = Util.EnvironmentTickCount();
5775 break;
5776 }
5777 }
5778
5779 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5465 { 5780 {
5466 RegenerateMaptile(); 5781 RegenerateMaptile();
5467 5782
@@ -5489,6 +5804,8 @@ namespace OpenSim.Region.Framework.Scenes
5489 /// <returns></returns> 5804 /// <returns></returns>
5490 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5805 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5491 { 5806 {
5807 reason = "You are banned from the region";
5808
5492 if (EntityTransferModule.IsInTransit(agentID)) 5809 if (EntityTransferModule.IsInTransit(agentID))
5493 { 5810 {
5494 reason = "Agent is still in transit from this region"; 5811 reason = "Agent is still in transit from this region";
@@ -5500,6 +5817,12 @@ namespace OpenSim.Region.Framework.Scenes
5500 return false; 5817 return false;
5501 } 5818 }
5502 5819
5820 if (Permissions.IsGod(agentID))
5821 {
5822 reason = String.Empty;
5823 return true;
5824 }
5825
5503 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5826 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5504 // However, the long term fix is to make sure root agent count is always accurate. 5827 // However, the long term fix is to make sure root agent count is always accurate.
5505 m_sceneGraph.RecalculateStats(); 5828 m_sceneGraph.RecalculateStats();
@@ -5520,6 +5843,41 @@ namespace OpenSim.Region.Framework.Scenes
5520 } 5843 }
5521 } 5844 }
5522 5845
5846 ScenePresence presence = GetScenePresence(agentID);
5847 IClientAPI client = null;
5848 AgentCircuitData aCircuit = null;
5849
5850 if (presence != null)
5851 {
5852 client = presence.ControllingClient;
5853 if (client != null)
5854 aCircuit = client.RequestClientInfo();
5855 }
5856
5857 // We may be called before there is a presence or a client.
5858 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5859 if (client == null)
5860 {
5861 aCircuit = new AgentCircuitData();
5862 aCircuit.AgentID = agentID;
5863 aCircuit.firstname = String.Empty;
5864 aCircuit.lastname = String.Empty;
5865 }
5866
5867 try
5868 {
5869 if (!AuthorizeUser(aCircuit, out reason))
5870 {
5871 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5872 return false;
5873 }
5874 }
5875 catch (Exception e)
5876 {
5877 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5878 return false;
5879 }
5880
5523 if (position == Vector3.Zero) // Teleport 5881 if (position == Vector3.Zero) // Teleport
5524 { 5882 {
5525 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5883 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5548,13 +5906,46 @@ namespace OpenSim.Region.Framework.Scenes
5548 } 5906 }
5549 } 5907 }
5550 } 5908 }
5909
5910 float posX = 128.0f;
5911 float posY = 128.0f;
5912
5913 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5914 {
5915 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5916 return false;
5917 }
5918 }
5919 else // Walking
5920 {
5921 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5922 if (land == null)
5923 return false;
5924
5925 bool banned = land.IsBannedFromLand(agentID);
5926 bool restricted = land.IsRestrictedFromLand(agentID);
5927
5928 if (banned || restricted)
5929 return false;
5551 } 5930 }
5552 5931
5553 reason = String.Empty; 5932 reason = String.Empty;
5554 return true; 5933 return true;
5555 } 5934 }
5556 5935
5557 /// <summary> 5936 public void StartTimerWatchdog()
5937 {
5938 m_timerWatchdog.Interval = 1000;
5939 m_timerWatchdog.Elapsed += TimerWatchdog;
5940 m_timerWatchdog.AutoReset = true;
5941 m_timerWatchdog.Start();
5942 }
5943
5944 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5945 {
5946 CheckHeartbeat();
5947 }
5948
5558 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5949 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5559 /// autopilot that moves an avatar to a sit target!. 5950 /// autopilot that moves an avatar to a sit target!.
5560 /// </summary> 5951 /// </summary>
@@ -5633,6 +6024,11 @@ namespace OpenSim.Region.Framework.Scenes
5633 return m_SpawnPoint - 1; 6024 return m_SpawnPoint - 1;
5634 } 6025 }
5635 6026
6027 private void HandleGcCollect(string module, string[] args)
6028 {
6029 GC.Collect();
6030 }
6031
5636 // Wrappers to get physics modules retrieve assets. Has to be done this way 6032 // Wrappers to get physics modules retrieve assets. Has to be done this way
5637 // because we can't assign the asset service to physics directly - at the 6033 // because we can't assign the asset service to physics directly - at the
5638 // time physics are instantiated it's not registered but it will be by 6034 // time physics are instantiated it's not registered but it will be by