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 2cdc4b3..9f87e1e 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
@@ -1778,7 +1834,7 @@ namespace OpenSim.Region.Framework.Scenes
1778 msg.fromAgentName = "Server"; 1834 msg.fromAgentName = "Server";
1779 msg.dialog = (byte)19; // Object msg 1835 msg.dialog = (byte)19; // Object msg
1780 msg.fromGroup = false; 1836 msg.fromGroup = false;
1781 msg.offline = (byte)0; 1837 msg.offline = (byte)1;
1782 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1838 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1783 msg.Position = Vector3.Zero; 1839 msg.Position = Vector3.Zero;
1784 msg.RegionID = RegionInfo.RegionID.Guid; 1840 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -2000,6 +2056,19 @@ namespace OpenSim.Region.Framework.Scenes
2000 EventManager.TriggerPrimsLoaded(this); 2056 EventManager.TriggerPrimsLoaded(this);
2001 } 2057 }
2002 2058
2059 public bool SuportsRayCastFiltered()
2060 {
2061 if (PhysicsScene == null)
2062 return false;
2063 return PhysicsScene.SuportsRaycastWorldFiltered();
2064 }
2065
2066 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2067 {
2068 if (PhysicsScene == null)
2069 return null;
2070 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
2071 }
2003 2072
2004 /// <summary> 2073 /// <summary>
2005 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 2074 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -2016,14 +2085,24 @@ namespace OpenSim.Region.Framework.Scenes
2016 /// <returns></returns> 2085 /// <returns></returns>
2017 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2086 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
2018 { 2087 {
2088
2089 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2090 Vector3 wpos = Vector3.Zero;
2091 // Check for water surface intersection from above
2092 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2093 {
2094 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2095 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2096 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2097 wpos.Z = wheight;
2098 }
2099
2019 Vector3 pos = Vector3.Zero; 2100 Vector3 pos = Vector3.Zero;
2020 if (RayEndIsIntersection == (byte)1) 2101 if (RayEndIsIntersection == (byte)1)
2021 { 2102 {
2022 pos = RayEnd; 2103 pos = RayEnd;
2023 return pos;
2024 } 2104 }
2025 2105 else if (RayTargetID != UUID.Zero)
2026 if (RayTargetID != UUID.Zero)
2027 { 2106 {
2028 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2107 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
2029 2108
@@ -2045,7 +2124,7 @@ namespace OpenSim.Region.Framework.Scenes
2045 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2124 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2046 2125
2047 // Un-comment out the following line to Get Raytrace results printed to the console. 2126 // Un-comment out the following line to Get Raytrace results printed to the console.
2048 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2127 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2049 float ScaleOffset = 0.5f; 2128 float ScaleOffset = 0.5f;
2050 2129
2051 // If we hit something 2130 // If we hit something
@@ -2068,13 +2147,10 @@ namespace OpenSim.Region.Framework.Scenes
2068 //pos.Z -= 0.25F; 2147 //pos.Z -= 0.25F;
2069 2148
2070 } 2149 }
2071
2072 return pos;
2073 } 2150 }
2074 else 2151 else
2075 { 2152 {
2076 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2153 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2077
2078 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2154 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2079 2155
2080 // Un-comment the following line to print the raytrace results to the console. 2156 // Un-comment the following line to print the raytrace results to the console.
@@ -2083,13 +2159,12 @@ namespace OpenSim.Region.Framework.Scenes
2083 if (ei.HitTF) 2159 if (ei.HitTF)
2084 { 2160 {
2085 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2161 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2086 } else 2162 }
2163 else
2087 { 2164 {
2088 // fall back to our stupid functionality 2165 // fall back to our stupid functionality
2089 pos = RayEnd; 2166 pos = RayEnd;
2090 } 2167 }
2091
2092 return pos;
2093 } 2168 }
2094 } 2169 }
2095 else 2170 else
@@ -2100,8 +2175,12 @@ namespace OpenSim.Region.Framework.Scenes
2100 //increase height so its above the ground. 2175 //increase height so its above the ground.
2101 //should be getting the normal of the ground at the rez point and using that? 2176 //should be getting the normal of the ground at the rez point and using that?
2102 pos.Z += scale.Z / 2f; 2177 pos.Z += scale.Z / 2f;
2103 return pos; 2178// return pos;
2104 } 2179 }
2180
2181 // check against posible water intercept
2182 if (wpos.Z > pos.Z) pos = wpos;
2183 return pos;
2105 } 2184 }
2106 2185
2107 2186
@@ -2192,12 +2271,12 @@ namespace OpenSim.Region.Framework.Scenes
2192 { 2271 {
2193 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) 2272 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2194 { 2273 {
2274 sceneObject.IsDeleted = false;
2195 EventManager.TriggerObjectAddedToScene(sceneObject); 2275 EventManager.TriggerObjectAddedToScene(sceneObject);
2196 return true; 2276 return true;
2197 } 2277 }
2198 2278
2199 return false; 2279 return false;
2200
2201 } 2280 }
2202 2281
2203 /// <summary> 2282 /// <summary>
@@ -2289,6 +2368,15 @@ namespace OpenSim.Region.Framework.Scenes
2289 /// </summary> 2368 /// </summary>
2290 public void DeleteAllSceneObjects() 2369 public void DeleteAllSceneObjects()
2291 { 2370 {
2371 DeleteAllSceneObjects(false);
2372 }
2373
2374 /// <summary>
2375 /// Delete every object from the scene. This does not include attachments worn by avatars.
2376 /// </summary>
2377 public void DeleteAllSceneObjects(bool exceptNoCopy)
2378 {
2379 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2292 lock (Entities) 2380 lock (Entities)
2293 { 2381 {
2294 EntityBase[] entities = Entities.GetEntities(); 2382 EntityBase[] entities = Entities.GetEntities();
@@ -2297,11 +2385,24 @@ namespace OpenSim.Region.Framework.Scenes
2297 if (e is SceneObjectGroup) 2385 if (e is SceneObjectGroup)
2298 { 2386 {
2299 SceneObjectGroup sog = (SceneObjectGroup)e; 2387 SceneObjectGroup sog = (SceneObjectGroup)e;
2300 if (!sog.IsAttachment) 2388 if (sog != null && !sog.IsAttachment)
2301 DeleteSceneObject((SceneObjectGroup)e, false); 2389 {
2390 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2391 {
2392 DeleteSceneObject((SceneObjectGroup)e, false);
2393 }
2394 else
2395 {
2396 toReturn.Add((SceneObjectGroup)e);
2397 }
2398 }
2302 } 2399 }
2303 } 2400 }
2304 } 2401 }
2402 if (toReturn.Count > 0)
2403 {
2404 returnObjects(toReturn.ToArray(), UUID.Zero);
2405 }
2305 } 2406 }
2306 2407
2307 /// <summary> 2408 /// <summary>
@@ -2336,6 +2437,12 @@ namespace OpenSim.Region.Framework.Scenes
2336 2437
2337 foreach (SceneObjectPart part in partList) 2438 foreach (SceneObjectPart part in partList)
2338 { 2439 {
2440 if (part.KeyframeMotion != null)
2441 {
2442 part.KeyframeMotion.Delete();
2443 part.KeyframeMotion = null;
2444 }
2445
2339 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) 2446 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
2340 { 2447 {
2341 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? 2448 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
@@ -2353,6 +2460,8 @@ namespace OpenSim.Region.Framework.Scenes
2353 } 2460 }
2354 2461
2355 group.DeleteGroupFromScene(silent); 2462 group.DeleteGroupFromScene(silent);
2463 if (!silent)
2464 SendKillObject(new List<uint>() { group.LocalId });
2356 2465
2357// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2466// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2358 } 2467 }
@@ -2643,7 +2752,7 @@ namespace OpenSim.Region.Framework.Scenes
2643 // If the user is banned, we won't let any of their objects 2752 // If the user is banned, we won't let any of their objects
2644 // enter. Period. 2753 // enter. Period.
2645 // 2754 //
2646 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2755 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2647 { 2756 {
2648 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2757 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2649 return false; 2758 return false;
@@ -2651,6 +2760,8 @@ namespace OpenSim.Region.Framework.Scenes
2651 2760
2652 if (newPosition != Vector3.Zero) 2761 if (newPosition != Vector3.Zero)
2653 newObject.RootPart.GroupPosition = newPosition; 2762 newObject.RootPart.GroupPosition = newPosition;
2763 if (newObject.RootPart.KeyframeMotion != null)
2764 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2654 2765
2655 if (!AddSceneObject(newObject)) 2766 if (!AddSceneObject(newObject))
2656 { 2767 {
@@ -2695,6 +2806,23 @@ namespace OpenSim.Region.Framework.Scenes
2695 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2806 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2696 public bool AddSceneObject(SceneObjectGroup sceneObject) 2807 public bool AddSceneObject(SceneObjectGroup sceneObject)
2697 { 2808 {
2809 if (sceneObject.OwnerID == UUID.Zero)
2810 {
2811 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2812 return false;
2813 }
2814
2815 // If the user is banned, we won't let any of their objects
2816 // enter. Period.
2817 //
2818 int flags = GetUserFlags(sceneObject.OwnerID);
2819 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2820 {
2821 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2822
2823 return false;
2824 }
2825
2698 // Force allocation of new LocalId 2826 // Force allocation of new LocalId
2699 // 2827 //
2700 SceneObjectPart[] parts = sceneObject.Parts; 2828 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2728,16 +2856,27 @@ namespace OpenSim.Region.Framework.Scenes
2728 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2856 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2729 2857
2730 if (AttachmentsModule != null) 2858 if (AttachmentsModule != null)
2731 AttachmentsModule.AttachObject(sp, grp, 0, false, false); 2859 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false);
2732 } 2860 }
2733 else 2861 else
2734 { 2862 {
2863 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2735 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2864 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2736 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2865 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2737 } 2866 }
2867 if (sceneObject.OwnerID == UUID.Zero)
2868 {
2869 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2870 return false;
2871 }
2738 } 2872 }
2739 else 2873 else
2740 { 2874 {
2875 if (sceneObject.OwnerID == UUID.Zero)
2876 {
2877 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2878 return false;
2879 }
2741 AddRestoredSceneObject(sceneObject, true, false); 2880 AddRestoredSceneObject(sceneObject, true, false);
2742 } 2881 }
2743 2882
@@ -2754,6 +2893,24 @@ namespace OpenSim.Region.Framework.Scenes
2754 return 2; // StateSource.PrimCrossing 2893 return 2; // StateSource.PrimCrossing
2755 } 2894 }
2756 2895
2896 public int GetUserFlags(UUID user)
2897 {
2898 //Unfortunately the SP approach means that the value is cached until region is restarted
2899 /*
2900 ScenePresence sp;
2901 if (TryGetScenePresence(user, out sp))
2902 {
2903 return sp.UserFlags;
2904 }
2905 else
2906 {
2907 */
2908 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2909 if (uac == null)
2910 return 0;
2911 return uac.UserFlags;
2912 //}
2913 }
2757 #endregion 2914 #endregion
2758 2915
2759 #region Add/Remove Avatar Methods 2916 #region Add/Remove Avatar Methods
@@ -2786,7 +2943,7 @@ namespace OpenSim.Region.Framework.Scenes
2786 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2943 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2787 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2944 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2788 2945
2789 // CheckHeartbeat(); 2946 CheckHeartbeat();
2790 2947
2791 sp = GetScenePresence(client.AgentId); 2948 sp = GetScenePresence(client.AgentId);
2792 2949
@@ -2930,19 +3087,14 @@ namespace OpenSim.Region.Framework.Scenes
2930 // and the scene presence and the client, if they exist 3087 // and the scene presence and the client, if they exist
2931 try 3088 try
2932 { 3089 {
2933 // We need to wait for the client to make UDP contact first. 3090 ScenePresence sp = GetScenePresence(agentID);
2934 // It's the UDP contact that creates the scene presence 3091
2935 ScenePresence sp = WaitGetScenePresence(agentID);
2936 if (sp != null) 3092 if (sp != null)
2937 { 3093 {
2938 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3094 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2939
2940 sp.ControllingClient.Close(); 3095 sp.ControllingClient.Close();
2941 } 3096 }
2942 else 3097
2943 {
2944 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2945 }
2946 // BANG! SLASH! 3098 // BANG! SLASH!
2947 m_authenticateHandler.RemoveCircuit(agentID); 3099 m_authenticateHandler.RemoveCircuit(agentID);
2948 3100
@@ -2987,6 +3139,8 @@ namespace OpenSim.Region.Framework.Scenes
2987 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3139 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2988 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3140 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2989 3141
3142 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3143
2990 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3144 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2991 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3145 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2992 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3146 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -3043,6 +3197,7 @@ namespace OpenSim.Region.Framework.Scenes
3043 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3197 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
3044 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3198 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
3045 client.OnCopyInventoryItem += CopyInventoryItem; 3199 client.OnCopyInventoryItem += CopyInventoryItem;
3200 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
3046 client.OnMoveInventoryItem += MoveInventoryItem; 3201 client.OnMoveInventoryItem += MoveInventoryItem;
3047 client.OnRemoveInventoryItem += RemoveInventoryItem; 3202 client.OnRemoveInventoryItem += RemoveInventoryItem;
3048 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3203 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3114,6 +3269,8 @@ namespace OpenSim.Region.Framework.Scenes
3114 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3269 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3115 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3270 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3116 3271
3272 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3273
3117 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3274 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3118 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3275 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3119 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3276 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3216,7 +3373,7 @@ namespace OpenSim.Region.Framework.Scenes
3216 /// </summary> 3373 /// </summary>
3217 /// <param name="agentId">The avatar's Unique ID</param> 3374 /// <param name="agentId">The avatar's Unique ID</param>
3218 /// <param name="client">The IClientAPI for the client</param> 3375 /// <param name="client">The IClientAPI for the client</param>
3219 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3376 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3220 { 3377 {
3221 if (EntityTransferModule != null) 3378 if (EntityTransferModule != null)
3222 { 3379 {
@@ -3227,6 +3384,7 @@ namespace OpenSim.Region.Framework.Scenes
3227 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3384 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3228 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3385 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3229 } 3386 }
3387 return false;
3230 } 3388 }
3231 3389
3232 /// <summary> 3390 /// <summary>
@@ -3336,6 +3494,16 @@ namespace OpenSim.Region.Framework.Scenes
3336 /// <param name="flags"></param> 3494 /// <param name="flags"></param>
3337 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3495 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3338 { 3496 {
3497 //Add half the avatar's height so that the user doesn't fall through prims
3498 ScenePresence presence;
3499 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3500 {
3501 if (presence.Appearance != null)
3502 {
3503 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3504 }
3505 }
3506
3339 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3507 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3340 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3508 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3341 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3509 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3472,6 +3640,7 @@ namespace OpenSim.Region.Framework.Scenes
3472 // It's possible for child agents to have transactions if changes are being made cross-border. 3640 // It's possible for child agents to have transactions if changes are being made cross-border.
3473 if (AgentTransactionsModule != null) 3641 if (AgentTransactionsModule != null)
3474 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3642 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3643 m_log.Debug("[Scene] The avatar has left the building");
3475 } 3644 }
3476 catch (Exception e) 3645 catch (Exception e)
3477 { 3646 {
@@ -3664,38 +3833,39 @@ namespace OpenSim.Region.Framework.Scenes
3664 agent.firstname, agent.lastname, agent.Viewer); 3833 agent.firstname, agent.lastname, agent.Viewer);
3665 reason = "Access denied, your viewer is banned by the region owner"; 3834 reason = "Access denied, your viewer is banned by the region owner";
3666 return false; 3835 return false;
3667 } 3836 }
3837
3668 3838
3669 ILandObject land; 3839 ScenePresence sp = GetScenePresence(agent.AgentID);
3840
3841 if (sp != null && !sp.IsChildAgent)
3842 {
3843 // We have a zombie from a crashed session.
3844 // Or the same user is trying to be root twice here, won't work.
3845 // Kill it.
3846 m_log.WarnFormat(
3847 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3848 sp.Name, sp.UUID, RegionInfo.RegionName);
3849
3850 sp.ControllingClient.Close(true, true);
3851 sp = null;
3852 }
3670 3853
3671 lock (agent) 3854 lock (agent)
3672 { 3855 {
3673 ScenePresence sp = GetScenePresence(agent.AgentID);
3674
3675 if (sp != null && !sp.IsChildAgent)
3676 {
3677 // We have a zombie from a crashed session.
3678 // Or the same user is trying to be root twice here, won't work.
3679 // Kill it.
3680 m_log.WarnFormat(
3681 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3682 sp.Name, sp.UUID, RegionInfo.RegionName);
3683
3684 sp.ControllingClient.Close(true);
3685 sp = null;
3686 }
3687
3688 land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3689
3690 //On login test land permisions 3856 //On login test land permisions
3691 if (vialogin) 3857 if (vialogin)
3692 { 3858 {
3693 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3859 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3860 if (cache != null)
3861 cache.Remove(agent.firstname + " " + agent.lastname);
3862 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3694 { 3863 {
3864 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3695 return false; 3865 return false;
3696 } 3866 }
3697 } 3867 }
3698 3868
3699 if (sp == null) // We don't have an [child] agent here already 3869 if (sp == null) // We don't have an [child] agent here already
3700 { 3870 {
3701 if (requirePresenceLookup) 3871 if (requirePresenceLookup)
@@ -3704,34 +3874,36 @@ namespace OpenSim.Region.Framework.Scenes
3704 { 3874 {
3705 if (!VerifyUserPresence(agent, out reason)) 3875 if (!VerifyUserPresence(agent, out reason))
3706 return false; 3876 return false;
3707 } 3877 } catch (Exception e)
3708 catch (Exception e)
3709 { 3878 {
3710 m_log.ErrorFormat( 3879 m_log.ErrorFormat(
3711 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3880 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
3712
3713 return false; 3881 return false;
3714 } 3882 }
3715 } 3883 }
3716 3884
3717 try 3885 try
3718 { 3886 {
3719 if (!AuthorizeUser(agent, out reason)) 3887 // Always check estate if this is a login. Always
3720 return false; 3888 // check if banned regions are to be blacked out.
3889 if (vialogin || (!m_seeIntoBannedRegion))
3890 {
3891 if (!AuthorizeUser(agent, out reason))
3892 return false;
3893 }
3721 } 3894 }
3722 catch (Exception e) 3895 catch (Exception e)
3723 { 3896 {
3724 m_log.ErrorFormat( 3897 m_log.ErrorFormat(
3725 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3898 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
3726
3727 return false; 3899 return false;
3728 } 3900 }
3729 3901
3730 m_log.InfoFormat( 3902 m_log.InfoFormat(
3731 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 3903 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3732 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3904 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3733 agent.AgentID, agent.circuitcode); 3905 agent.AgentID, agent.circuitcode);
3734 3906
3735 if (CapsModule != null) 3907 if (CapsModule != null)
3736 { 3908 {
3737 CapsModule.SetAgentCapsSeeds(agent); 3909 CapsModule.SetAgentCapsSeeds(agent);
@@ -3743,15 +3915,15 @@ namespace OpenSim.Region.Framework.Scenes
3743 // Let the SP know how we got here. This has a lot of interesting 3915 // Let the SP know how we got here. This has a lot of interesting
3744 // uses down the line. 3916 // uses down the line.
3745 sp.TeleportFlags = (TPFlags)teleportFlags; 3917 sp.TeleportFlags = (TPFlags)teleportFlags;
3746 3918
3747 if (sp.IsChildAgent) 3919 if (sp.IsChildAgent)
3748 { 3920 {
3749 m_log.DebugFormat( 3921 m_log.DebugFormat(
3750 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", 3922 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
3751 agent.AgentID, RegionInfo.RegionName); 3923 agent.AgentID, RegionInfo.RegionName);
3752 3924
3753 sp.AdjustKnownSeeds(); 3925 sp.AdjustKnownSeeds();
3754 3926
3755 if (CapsModule != null) 3927 if (CapsModule != null)
3756 CapsModule.SetAgentCapsSeeds(agent); 3928 CapsModule.SetAgentCapsSeeds(agent);
3757 } 3929 }
@@ -3853,6 +4025,8 @@ namespace OpenSim.Region.Framework.Scenes
3853 } 4025 }
3854 4026
3855 // Honor parcel landing type and position. 4027 // Honor parcel landing type and position.
4028 /*
4029 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3856 if (land != null) 4030 if (land != null)
3857 { 4031 {
3858 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 4032 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3860,25 +4034,43 @@ namespace OpenSim.Region.Framework.Scenes
3860 agent.startpos = land.LandData.UserLocation; 4034 agent.startpos = land.LandData.UserLocation;
3861 } 4035 }
3862 } 4036 }
4037 */// This is now handled properly in ScenePresence.MakeRootAgent
3863 } 4038 }
3864 4039
3865 return true; 4040 return true;
3866 } 4041 }
3867 4042
3868 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 4043 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3869 { 4044 {
3870 bool banned = land.IsBannedFromLand(agent.AgentID); 4045 if (posX < 0)
3871 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 4046 posX = 0;
4047 else if (posX >= 256)
4048 posX = 255.999f;
4049 if (posY < 0)
4050 posY = 0;
4051 else if (posY >= 256)
4052 posY = 255.999f;
4053
4054 reason = String.Empty;
4055 if (Permissions.IsGod(agentID))
4056 return true;
4057
4058 ILandObject land = LandChannel.GetLandObject(posX, posY);
4059 if (land == null)
4060 return false;
4061
4062 bool banned = land.IsBannedFromLand(agentID);
4063 bool restricted = land.IsRestrictedFromLand(agentID);
3872 4064
3873 if (banned || restricted) 4065 if (banned || restricted)
3874 { 4066 {
3875 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 4067 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3876 if (nearestParcel != null) 4068 if (nearestParcel != null)
3877 { 4069 {
3878 //Move agent to nearest allowed 4070 //Move agent to nearest allowed
3879 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 4071 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3880 agent.startpos.X = newPosition.X; 4072 posX = newPosition.X;
3881 agent.startpos.Y = newPosition.Y; 4073 posY = newPosition.Y;
3882 } 4074 }
3883 else 4075 else
3884 { 4076 {
@@ -3940,7 +4132,7 @@ namespace OpenSim.Region.Framework.Scenes
3940 4132
3941 if (!m_strictAccessControl) return true; 4133 if (!m_strictAccessControl) return true;
3942 if (Permissions.IsGod(agent.AgentID)) return true; 4134 if (Permissions.IsGod(agent.AgentID)) return true;
3943 4135
3944 if (AuthorizationService != null) 4136 if (AuthorizationService != null)
3945 { 4137 {
3946 if (!AuthorizationService.IsAuthorizedForRegion( 4138 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3955,7 +4147,7 @@ namespace OpenSim.Region.Framework.Scenes
3955 4147
3956 if (RegionInfo.EstateSettings != null) 4148 if (RegionInfo.EstateSettings != null)
3957 { 4149 {
3958 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4150 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3959 { 4151 {
3960 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4152 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3961 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4153 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4145,6 +4337,15 @@ namespace OpenSim.Region.Framework.Scenes
4145 4337
4146 // XPTO: if this agent is not allowed here as root, always return false 4338 // XPTO: if this agent is not allowed here as root, always return false
4147 4339
4340 // We have to wait until the viewer contacts this region after receiving EAC.
4341 // That calls AddNewClient, which finally creates the ScenePresence
4342 int flags = GetUserFlags(cAgentData.AgentID);
4343 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4344 {
4345 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4346 return false;
4347 }
4348
4148 // TODO: This check should probably be in QueryAccess(). 4349 // TODO: This check should probably be in QueryAccess().
4149 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4350 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4150 if (nearestParcel == null) 4351 if (nearestParcel == null)
@@ -4209,7 +4410,7 @@ namespace OpenSim.Region.Framework.Scenes
4209 /// <param name='agentID'></param> 4410 /// <param name='agentID'></param>
4210 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4411 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4211 { 4412 {
4212 int ntimes = 10; 4413 int ntimes = 30;
4213 ScenePresence sp = null; 4414 ScenePresence sp = null;
4214 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4415 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4215 Thread.Sleep(1000); 4416 Thread.Sleep(1000);
@@ -4239,6 +4440,16 @@ namespace OpenSim.Region.Framework.Scenes
4239 return false; 4440 return false;
4240 } 4441 }
4241 4442
4443 public bool IncomingCloseAgent(UUID agentID)
4444 {
4445 return IncomingCloseAgent(agentID, false);
4446 }
4447
4448 public bool IncomingCloseChildAgent(UUID agentID)
4449 {
4450 return IncomingCloseAgent(agentID, true);
4451 }
4452
4242 /// <summary> 4453 /// <summary>
4243 /// Tell a single agent to disconnect from the region. 4454 /// Tell a single agent to disconnect from the region.
4244 /// </summary> 4455 /// </summary>
@@ -4254,7 +4465,7 @@ namespace OpenSim.Region.Framework.Scenes
4254 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4465 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4255 if (presence != null) 4466 if (presence != null)
4256 { 4467 {
4257 presence.ControllingClient.Close(force); 4468 presence.ControllingClient.Close(force, force);
4258 return true; 4469 return true;
4259 } 4470 }
4260 4471
@@ -4914,35 +5125,81 @@ namespace OpenSim.Region.Framework.Scenes
4914 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5125 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4915 } 5126 }
4916 5127
4917 public int GetHealth() 5128 public int GetHealth(out int flags, out string message)
4918 { 5129 {
4919 // Returns: 5130 // Returns:
4920 // 1 = sim is up and accepting http requests. The heartbeat has 5131 // 1 = sim is up and accepting http requests. The heartbeat has
4921 // stopped and the sim is probably locked up, but a remote 5132 // stopped and the sim is probably locked up, but a remote
4922 // admin restart may succeed 5133 // admin restart may succeed
4923 // 5134 //
4924 // 2 = Sim is up and the heartbeat is running. The sim is likely 5135 // 2 = Sim is up and the heartbeat is running. The sim is likely
4925 // usable for people within and logins _may_ work 5136 // usable for people within
4926 // 5137 //
4927 // 3 = We have seen a new user enter within the past 4 minutes 5138 // 3 = Sim is up and one packet thread is running. Sim is
5139 // unstable and will not accept new logins
5140 //
5141 // 4 = Sim is up and both packet threads are running. Sim is
5142 // likely usable
5143 //
5144 // 5 = We have seen a new user enter within the past 4 minutes
4928 // which can be seen as positive confirmation of sim health 5145 // which can be seen as positive confirmation of sim health
4929 // 5146 //
5147
5148 flags = 0;
5149 message = String.Empty;
5150
5151 CheckHeartbeat();
5152
5153 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5154 {
5155 // We're still starting
5156 // 0 means "in startup", it can't happen another way, since
5157 // to get here, we must be able to accept http connections
5158 return 0;
5159 }
5160
4930 int health=1; // Start at 1, means we're up 5161 int health=1; // Start at 1, means we're up
4931 5162
4932 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5163 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4933 health += 1; 5164 {
5165 health+=1;
5166 flags |= 1;
5167 }
5168
5169 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5170 {
5171 health+=1;
5172 flags |= 2;
5173 }
5174
5175 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5176 {
5177 health+=1;
5178 flags |= 4;
5179 }
4934 else 5180 else
5181 {
5182int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5183System.Diagnostics.Process proc = new System.Diagnostics.Process();
5184proc.EnableRaisingEvents=false;
5185proc.StartInfo.FileName = "/bin/kill";
5186proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5187proc.Start();
5188proc.WaitForExit();
5189Thread.Sleep(1000);
5190Environment.Exit(1);
5191 }
5192
5193 if (flags != 7)
4935 return health; 5194 return health;
4936 5195
4937 // A login in the last 4 mins? We can't be doing too badly 5196 // A login in the last 4 mins? We can't be doing too badly
4938 // 5197 //
4939 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5198 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4940 health++; 5199 health++;
4941 else 5200 else
4942 return health; 5201 return health;
4943 5202
4944// CheckHeartbeat();
4945
4946 return health; 5203 return health;
4947 } 5204 }
4948 5205
@@ -5030,7 +5287,7 @@ namespace OpenSim.Region.Framework.Scenes
5030 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5287 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5031 if (wasUsingPhysics) 5288 if (wasUsingPhysics)
5032 { 5289 {
5033 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 5290 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
5034 } 5291 }
5035 } 5292 }
5036 5293
@@ -5129,14 +5386,14 @@ namespace OpenSim.Region.Framework.Scenes
5129 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5386 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5130 } 5387 }
5131 5388
5132// private void CheckHeartbeat() 5389 private void CheckHeartbeat()
5133// { 5390 {
5134// if (m_firstHeartbeat) 5391 if (m_firstHeartbeat)
5135// return; 5392 return;
5136// 5393
5137// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5394 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5138// StartTimer(); 5395 Start();
5139// } 5396 }
5140 5397
5141 public override ISceneObject DeserializeObject(string representation) 5398 public override ISceneObject DeserializeObject(string representation)
5142 { 5399 {
@@ -5148,9 +5405,14 @@ namespace OpenSim.Region.Framework.Scenes
5148 get { return m_allowScriptCrossings; } 5405 get { return m_allowScriptCrossings; }
5149 } 5406 }
5150 5407
5151 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5408 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5152 { 5409 {
5153 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5410 return GetNearestAllowedPosition(avatar, null);
5411 }
5412
5413 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5414 {
5415 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
5154 5416
5155 if (nearestParcel != null) 5417 if (nearestParcel != null)
5156 { 5418 {
@@ -5159,10 +5421,7 @@ namespace OpenSim.Region.Framework.Scenes
5159 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5421 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5160 if (nearestPoint != null) 5422 if (nearestPoint != null)
5161 { 5423 {
5162// m_log.DebugFormat( 5424 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
5163// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
5164// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
5165
5166 return nearestPoint.Value; 5425 return nearestPoint.Value;
5167 } 5426 }
5168 5427
@@ -5172,17 +5431,20 @@ namespace OpenSim.Region.Framework.Scenes
5172 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5431 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5173 if (nearestPoint != null) 5432 if (nearestPoint != null)
5174 { 5433 {
5175// m_log.DebugFormat( 5434 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5176// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
5177
5178 return nearestPoint.Value; 5435 return nearestPoint.Value;
5179 } 5436 }
5180 5437
5181 //Ultimate backup if we have no idea where they are 5438 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5182// m_log.DebugFormat( 5439 if (dest != excludeParcel)
5183// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5440 {
5441 // Ultimate backup if we have no idea where they are and
5442 // the last allowed position was in another parcel
5443 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5444 return avatar.lastKnownAllowedPosition;
5445 }
5184 5446
5185 return avatar.lastKnownAllowedPosition; 5447 // else fall through to region edge
5186 } 5448 }
5187 5449
5188 //Go to the edge, this happens in teleporting to a region with no available parcels 5450 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -5216,13 +5478,18 @@ namespace OpenSim.Region.Framework.Scenes
5216 5478
5217 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5479 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5218 { 5480 {
5481 return GetNearestAllowedParcel(avatarId, x, y, null);
5482 }
5483
5484 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5485 {
5219 List<ILandObject> all = AllParcels(); 5486 List<ILandObject> all = AllParcels();
5220 float minParcelDistance = float.MaxValue; 5487 float minParcelDistance = float.MaxValue;
5221 ILandObject nearestParcel = null; 5488 ILandObject nearestParcel = null;
5222 5489
5223 foreach (var parcel in all) 5490 foreach (var parcel in all)
5224 { 5491 {
5225 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5492 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5226 { 5493 {
5227 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5494 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5228 if (parcelDistance < minParcelDistance) 5495 if (parcelDistance < minParcelDistance)
@@ -5464,7 +5731,55 @@ namespace OpenSim.Region.Framework.Scenes
5464 mapModule.GenerateMaptile(); 5731 mapModule.GenerateMaptile();
5465 } 5732 }
5466 5733
5467 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5734// public void CleanDroppedAttachments()
5735// {
5736// List<SceneObjectGroup> objectsToDelete =
5737// new List<SceneObjectGroup>();
5738//
5739// lock (m_cleaningAttachments)
5740// {
5741// ForEachSOG(delegate (SceneObjectGroup grp)
5742// {
5743// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5744// {
5745// UUID agentID = grp.OwnerID;
5746// if (agentID == UUID.Zero)
5747// {
5748// objectsToDelete.Add(grp);
5749// return;
5750// }
5751//
5752// ScenePresence sp = GetScenePresence(agentID);
5753// if (sp == null)
5754// {
5755// objectsToDelete.Add(grp);
5756// return;
5757// }
5758// }
5759// });
5760// }
5761//
5762// foreach (SceneObjectGroup grp in objectsToDelete)
5763// {
5764// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5765// DeleteSceneObject(grp, true);
5766// }
5767// }
5768
5769 public void ThreadAlive(int threadCode)
5770 {
5771 switch(threadCode)
5772 {
5773 case 1: // Incoming
5774 m_lastIncoming = Util.EnvironmentTickCount();
5775 break;
5776 case 2: // Incoming
5777 m_lastOutgoing = Util.EnvironmentTickCount();
5778 break;
5779 }
5780 }
5781
5782 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5468 { 5783 {
5469 RegenerateMaptile(); 5784 RegenerateMaptile();
5470 5785
@@ -5492,6 +5807,8 @@ namespace OpenSim.Region.Framework.Scenes
5492 /// <returns></returns> 5807 /// <returns></returns>
5493 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5808 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5494 { 5809 {
5810 reason = "You are banned from the region";
5811
5495 if (EntityTransferModule.IsInTransit(agentID)) 5812 if (EntityTransferModule.IsInTransit(agentID))
5496 { 5813 {
5497 reason = "Agent is still in transit from this region"; 5814 reason = "Agent is still in transit from this region";
@@ -5503,6 +5820,12 @@ namespace OpenSim.Region.Framework.Scenes
5503 return false; 5820 return false;
5504 } 5821 }
5505 5822
5823 if (Permissions.IsGod(agentID))
5824 {
5825 reason = String.Empty;
5826 return true;
5827 }
5828
5506 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5829 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5507 // However, the long term fix is to make sure root agent count is always accurate. 5830 // However, the long term fix is to make sure root agent count is always accurate.
5508 m_sceneGraph.RecalculateStats(); 5831 m_sceneGraph.RecalculateStats();
@@ -5523,6 +5846,41 @@ namespace OpenSim.Region.Framework.Scenes
5523 } 5846 }
5524 } 5847 }
5525 5848
5849 ScenePresence presence = GetScenePresence(agentID);
5850 IClientAPI client = null;
5851 AgentCircuitData aCircuit = null;
5852
5853 if (presence != null)
5854 {
5855 client = presence.ControllingClient;
5856 if (client != null)
5857 aCircuit = client.RequestClientInfo();
5858 }
5859
5860 // We may be called before there is a presence or a client.
5861 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5862 if (client == null)
5863 {
5864 aCircuit = new AgentCircuitData();
5865 aCircuit.AgentID = agentID;
5866 aCircuit.firstname = String.Empty;
5867 aCircuit.lastname = String.Empty;
5868 }
5869
5870 try
5871 {
5872 if (!AuthorizeUser(aCircuit, out reason))
5873 {
5874 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5875 return false;
5876 }
5877 }
5878 catch (Exception e)
5879 {
5880 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5881 return false;
5882 }
5883
5526 if (position == Vector3.Zero) // Teleport 5884 if (position == Vector3.Zero) // Teleport
5527 { 5885 {
5528 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5886 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5551,13 +5909,46 @@ namespace OpenSim.Region.Framework.Scenes
5551 } 5909 }
5552 } 5910 }
5553 } 5911 }
5912
5913 float posX = 128.0f;
5914 float posY = 128.0f;
5915
5916 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5917 {
5918 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5919 return false;
5920 }
5921 }
5922 else // Walking
5923 {
5924 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5925 if (land == null)
5926 return false;
5927
5928 bool banned = land.IsBannedFromLand(agentID);
5929 bool restricted = land.IsRestrictedFromLand(agentID);
5930
5931 if (banned || restricted)
5932 return false;
5554 } 5933 }
5555 5934
5556 reason = String.Empty; 5935 reason = String.Empty;
5557 return true; 5936 return true;
5558 } 5937 }
5559 5938
5560 /// <summary> 5939 public void StartTimerWatchdog()
5940 {
5941 m_timerWatchdog.Interval = 1000;
5942 m_timerWatchdog.Elapsed += TimerWatchdog;
5943 m_timerWatchdog.AutoReset = true;
5944 m_timerWatchdog.Start();
5945 }
5946
5947 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5948 {
5949 CheckHeartbeat();
5950 }
5951
5561 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5952 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5562 /// autopilot that moves an avatar to a sit target!. 5953 /// autopilot that moves an avatar to a sit target!.
5563 /// </summary> 5954 /// </summary>
@@ -5636,6 +6027,11 @@ namespace OpenSim.Region.Framework.Scenes
5636 return m_SpawnPoint - 1; 6027 return m_SpawnPoint - 1;
5637 } 6028 }
5638 6029
6030 private void HandleGcCollect(string module, string[] args)
6031 {
6032 GC.Collect();
6033 }
6034
5639 // Wrappers to get physics modules retrieve assets. Has to be done this way 6035 // Wrappers to get physics modules retrieve assets. Has to be done this way
5640 // because we can't assign the asset service to physics directly - at the 6036 // because we can't assign the asset service to physics directly - at the
5641 // time physics are instantiated it's not registered but it will be by 6037 // time physics are instantiated it's not registered but it will be by