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.cs830
1 files changed, 623 insertions, 207 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c2c0b96..66cce60 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -151,6 +151,7 @@ namespace OpenSim.Region.Framework.Scenes
151 // TODO: need to figure out how allow client agents but deny 151 // TODO: need to figure out how allow client agents but deny
152 // root agents when ACL denies access to root agent 152 // root agents when ACL denies access to root agent
153 public bool m_strictAccessControl = true; 153 public bool m_strictAccessControl = true;
154 public bool m_seeIntoBannedRegion = false;
154 public int MaxUndoCount = 5; 155 public int MaxUndoCount = 5;
155 156
156 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 157 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
@@ -167,12 +168,14 @@ namespace OpenSim.Region.Framework.Scenes
167 168
168 protected int m_splitRegionID; 169 protected int m_splitRegionID;
169 protected Timer m_restartWaitTimer = new Timer(); 170 protected Timer m_restartWaitTimer = new Timer();
171 protected Timer m_timerWatchdog = new Timer();
170 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 172 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
171 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 173 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
172 protected string m_simulatorVersion = "OpenSimulator Server"; 174 protected string m_simulatorVersion = "OpenSimulator Server";
173 protected ModuleLoader m_moduleLoader; 175 protected ModuleLoader m_moduleLoader;
174 protected AgentCircuitManager m_authenticateHandler; 176 protected AgentCircuitManager m_authenticateHandler;
175 protected SceneCommunicationService m_sceneGridService; 177 protected SceneCommunicationService m_sceneGridService;
178 protected ISnmpModule m_snmpService = null;
176 179
177 protected ISimulationDataService m_SimulationDataService; 180 protected ISimulationDataService m_SimulationDataService;
178 protected IEstateDataService m_EstateDataService; 181 protected IEstateDataService m_EstateDataService;
@@ -235,8 +238,8 @@ namespace OpenSim.Region.Framework.Scenes
235 private int m_update_presences = 1; // Update scene presence movements 238 private int m_update_presences = 1; // Update scene presence movements
236 private int m_update_events = 1; 239 private int m_update_events = 1;
237 private int m_update_backup = 200; 240 private int m_update_backup = 200;
238 private int m_update_terrain = 50; 241 private int m_update_terrain = 1000;
239// private int m_update_land = 1; 242 private int m_update_land = 10;
240 private int m_update_coarse_locations = 50; 243 private int m_update_coarse_locations = 50;
241 244
242 private int agentMS; 245 private int agentMS;
@@ -249,13 +252,13 @@ namespace OpenSim.Region.Framework.Scenes
249 private int backupMS; 252 private int backupMS;
250 private int terrainMS; 253 private int terrainMS;
251 private int landMS; 254 private int landMS;
252 private int spareMS;
253 255
254 /// <summary> 256 /// <summary>
255 /// Tick at which the last frame was processed. 257 /// Tick at which the last frame was processed.
256 /// </summary> 258 /// </summary>
257 private int m_lastFrameTick; 259 private int m_lastFrameTick;
258 260
261 public bool CombineRegions = false;
259 /// <summary> 262 /// <summary>
260 /// Tick at which the last maintenance run occurred. 263 /// Tick at which the last maintenance run occurred.
261 /// </summary> 264 /// </summary>
@@ -286,6 +289,11 @@ namespace OpenSim.Region.Framework.Scenes
286 /// </summary> 289 /// </summary>
287 private int m_LastLogin; 290 private int m_LastLogin;
288 291
292 private int m_lastIncoming;
293 private int m_lastOutgoing;
294 private int m_hbRestarts = 0;
295
296
289 /// <summary> 297 /// <summary>
290 /// Thread that runs the scene loop. 298 /// Thread that runs the scene loop.
291 /// </summary> 299 /// </summary>
@@ -301,7 +309,7 @@ namespace OpenSim.Region.Framework.Scenes
301 private volatile bool m_shuttingDown; 309 private volatile bool m_shuttingDown;
302 310
303// private int m_lastUpdate; 311// private int m_lastUpdate;
304// private bool m_firstHeartbeat = true; 312 private bool m_firstHeartbeat = true;
305 313
306 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 314 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
307 private bool m_reprioritizationEnabled = true; 315 private bool m_reprioritizationEnabled = true;
@@ -346,6 +354,19 @@ namespace OpenSim.Region.Framework.Scenes
346 get { return m_sceneGridService; } 354 get { return m_sceneGridService; }
347 } 355 }
348 356
357 public ISnmpModule SnmpService
358 {
359 get
360 {
361 if (m_snmpService == null)
362 {
363 m_snmpService = RequestModuleInterface<ISnmpModule>();
364 }
365
366 return m_snmpService;
367 }
368 }
369
349 public ISimulationDataService SimulationDataService 370 public ISimulationDataService SimulationDataService
350 { 371 {
351 get 372 get
@@ -645,6 +666,8 @@ namespace OpenSim.Region.Framework.Scenes
645 m_SimulationDataService = simDataService; 666 m_SimulationDataService = simDataService;
646 m_EstateDataService = estateDataService; 667 m_EstateDataService = estateDataService;
647 m_regionHandle = RegionInfo.RegionHandle; 668 m_regionHandle = RegionInfo.RegionHandle;
669 m_lastIncoming = 0;
670 m_lastOutgoing = 0;
648 671
649 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 672 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
650 m_asyncSceneObjectDeleter.Enabled = true; 673 m_asyncSceneObjectDeleter.Enabled = true;
@@ -727,137 +750,148 @@ namespace OpenSim.Region.Framework.Scenes
727 750
728 // Region config overrides global config 751 // Region config overrides global config
729 // 752 //
730 if (m_config.Configs["Startup"] != null) 753 try
731 { 754 {
732 IConfig startupConfig = m_config.Configs["Startup"]; 755 if (m_config.Configs["Startup"] != null)
733 756 {
734 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 757 IConfig startupConfig = m_config.Configs["Startup"];
735 758
736 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); 759 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
737 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
738 if (!m_useBackup)
739 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
740
741 //Animation states
742 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
743 760
744 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); 761 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
745 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); 762 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
763 if (!m_useBackup)
764 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
765
766 //Animation states
767 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
746 768
747 m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys); 769 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
748 if (RegionInfo.NonphysPrimMin > 0) 770 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
749 {
750 m_minNonphys = RegionInfo.NonphysPrimMin;
751 }
752 771
753 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); 772 m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys);
754 if (RegionInfo.NonphysPrimMax > 0) 773 if (RegionInfo.NonphysPrimMin > 0)
755 { 774 {
756 m_maxNonphys = RegionInfo.NonphysPrimMax; 775 m_minNonphys = RegionInfo.NonphysPrimMin;
757 } 776 }
758 777
759 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); 778 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
760 if (RegionInfo.PhysPrimMin > 0) 779 if (RegionInfo.NonphysPrimMax > 0)
761 { 780 {
762 m_minPhys = RegionInfo.PhysPrimMin; 781 m_maxNonphys = RegionInfo.NonphysPrimMax;
763 } 782 }
764 783
765 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 784 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
766 if (RegionInfo.PhysPrimMax > 0) 785 if (RegionInfo.PhysPrimMin > 0)
767 { 786 {
768 m_maxPhys = RegionInfo.PhysPrimMax; 787 m_minPhys = RegionInfo.PhysPrimMin;
769 } 788 }
770 789
771 // Here, if clamping is requested in either global or 790 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
772 // local config, it will be used
773 //
774 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
775 if (RegionInfo.ClampPrimSize)
776 {
777 m_clampPrimSize = true;
778 }
779 791
780 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 792 if (RegionInfo.PhysPrimMax > 0)
781 if (RegionInfo.LinksetCapacity > 0) 793 {
782 { 794 m_maxPhys = RegionInfo.PhysPrimMax;
783 m_linksetCapacity = RegionInfo.LinksetCapacity; 795 }
784 }
785 796
786 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 797 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
787 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 798 if (RegionInfo.LinksetCapacity > 0)
788 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 799 {
789 m_dontPersistBefore = 800 m_linksetCapacity = RegionInfo.LinksetCapacity;
790 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); 801 }
791 m_dontPersistBefore *= 10000000;
792 m_persistAfter =
793 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
794 m_persistAfter *= 10000000;
795 802
796 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 803 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
804 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
797 805
798 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 806 // Here, if clamping is requested in either global or
799 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 807 // local config, it will be used
808 //
809 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
810 if (RegionInfo.ClampPrimSize)
811 {
812 m_clampPrimSize = true;
813 }
800 814
801 IConfig packetConfig = m_config.Configs["PacketPool"]; 815 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
802 if (packetConfig != null) 816 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
803 { 817 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
804 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); 818 m_dontPersistBefore =
805 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); 819 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
806 } 820 m_dontPersistBefore *= 10000000;
821 m_persistAfter =
822 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
823 m_persistAfter *= 10000000;
824
825 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
826 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
827
828 IConfig packetConfig = m_config.Configs["PacketPool"];
829 if (packetConfig != null)
830 {
831 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
832 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
833 }
807 834
808 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 835 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
836 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
837 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
809 838
810 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 839 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
811 if (m_generateMaptiles) 840 if (m_generateMaptiles)
812 {
813 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
814 if (maptileRefresh != 0)
815 { 841 {
816 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 842 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
817 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; 843 if (maptileRefresh != 0)
818 m_mapGenerationTimer.AutoReset = true; 844 {
819 m_mapGenerationTimer.Start(); 845 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
846 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
847 m_mapGenerationTimer.AutoReset = true;
848 m_mapGenerationTimer.Start();
849 }
820 } 850 }
821 } 851 else
822 else
823 {
824 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
825 UUID tileID;
826
827 if (UUID.TryParse(tile, out tileID))
828 { 852 {
829 RegionInfo.RegionSettings.TerrainImageID = tileID; 853 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
854 UUID tileID;
855
856 if (UUID.TryParse(tile, out tileID))
857 {
858 RegionInfo.RegionSettings.TerrainImageID = tileID;
859 }
830 } 860 }
831 }
832 861
833 string grant = startupConfig.GetString("AllowedClients", String.Empty); 862 string grant = startupConfig.GetString("AllowedClients", String.Empty);
834 if (grant.Length > 0) 863 if (grant.Length > 0)
835 {
836 foreach (string viewer in grant.Split('|'))
837 { 864 {
838 m_AllowedViewers.Add(viewer.Trim().ToLower()); 865 foreach (string viewer in grant.Split(','))
866 {
867 m_AllowedViewers.Add(viewer.Trim().ToLower());
868 }
839 } 869 }
840 }
841 870
842 grant = startupConfig.GetString("BannedClients", String.Empty); 871 grant = startupConfig.GetString("BannedClients", String.Empty);
843 if (grant.Length > 0) 872 if (grant.Length > 0)
844 {
845 foreach (string viewer in grant.Split('|'))
846 { 873 {
847 m_BannedViewers.Add(viewer.Trim().ToLower()); 874 foreach (string viewer in grant.Split(','))
875 {
876 m_BannedViewers.Add(viewer.Trim().ToLower());
877 }
848 } 878 }
849 }
850 879
851 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 880 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
852 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 881 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
853 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 882 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
854 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 883 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
855 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 884 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
856 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); 885 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
857 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); 886 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
858 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); 887 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
859 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 888 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
860 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 889 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
890 }
891 }
892 catch (Exception e)
893 {
894 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
861 } 895 }
862 896
863 // FIXME: Ultimately this should be in a module. 897 // FIXME: Ultimately this should be in a module.
@@ -900,6 +934,8 @@ namespace OpenSim.Region.Framework.Scenes
900 StatsReporter = new SimStatsReporter(this); 934 StatsReporter = new SimStatsReporter(this);
901 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 935 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
902 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 936 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
937
938 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
903 } 939 }
904 940
905 public Scene(RegionInfo regInfo) : base(regInfo) 941 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1302,7 +1338,22 @@ namespace OpenSim.Region.Framework.Scenes
1302 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1338 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1303 if (m_heartbeatThread != null) 1339 if (m_heartbeatThread != null)
1304 { 1340 {
1341 m_hbRestarts++;
1342 if(m_hbRestarts > 10)
1343 Environment.Exit(1);
1344 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1345
1346//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1347//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1348//proc.EnableRaisingEvents=false;
1349//proc.StartInfo.FileName = "/bin/kill";
1350//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1351//proc.Start();
1352//proc.WaitForExit();
1353//Thread.Sleep(1000);
1354//Environment.Exit(1);
1305 m_heartbeatThread.Abort(); 1355 m_heartbeatThread.Abort();
1356 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1306 m_heartbeatThread = null; 1357 m_heartbeatThread = null;
1307 } 1358 }
1308// m_lastUpdate = Util.EnvironmentTickCount(); 1359// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1449,16 +1500,20 @@ namespace OpenSim.Region.Framework.Scenes
1449 endFrame = Frame + frames; 1500 endFrame = Frame + frames;
1450 1501
1451 float physicsFPS = 0f; 1502 float physicsFPS = 0f;
1452 int previousFrameTick, tmpMS; 1503 int tmpMS;
1453 int maintc = Util.EnvironmentTickCount(); 1504 int previousFrameTick;
1505 int maintc;
1506 int sleepMS;
1507 int framestart;
1454 1508
1455 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1509 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1456 { 1510 {
1511 framestart = Util.EnvironmentTickCount();
1457 ++Frame; 1512 ++Frame;
1458 1513
1459// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1514// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1460 1515
1461 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1516 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1462 1517
1463 try 1518 try
1464 { 1519 {
@@ -1510,6 +1565,7 @@ namespace OpenSim.Region.Framework.Scenes
1510 m_sceneGraph.UpdatePresences(); 1565 m_sceneGraph.UpdatePresences();
1511 1566
1512 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1567 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1568
1513 1569
1514 // Delete temp-on-rez stuff 1570 // Delete temp-on-rez stuff
1515 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1571 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1591,34 +1647,37 @@ namespace OpenSim.Region.Framework.Scenes
1591 1647
1592 Watchdog.UpdateThread(); 1648 Watchdog.UpdateThread();
1593 1649
1650 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1651
1652 StatsReporter.AddPhysicsFPS(physicsFPS);
1653 StatsReporter.AddTimeDilation(TimeDilation);
1654 StatsReporter.AddFPS(1);
1655
1656 StatsReporter.addAgentMS(agentMS);
1657 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1658 StatsReporter.addOtherMS(otherMS);
1659 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1660
1594 previousFrameTick = m_lastFrameTick; 1661 previousFrameTick = m_lastFrameTick;
1595 m_lastFrameTick = Util.EnvironmentTickCount(); 1662 m_lastFrameTick = Util.EnvironmentTickCount();
1596 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1663 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1597 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1664 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1598 1665
1666 m_firstHeartbeat = false;
1667
1668 sleepMS = Util.EnvironmentTickCount();
1669
1599 if (tmpMS > 0) 1670 if (tmpMS > 0)
1600 {
1601 Thread.Sleep(tmpMS); 1671 Thread.Sleep(tmpMS);
1602 spareMS += tmpMS;
1603 }
1604 1672
1605 frameMS = Util.EnvironmentTickCountSubtract(maintc); 1673 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1606 maintc = Util.EnvironmentTickCount(); 1674 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1607 1675 StatsReporter.addSleepMS(sleepMS);
1608 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1676 StatsReporter.addFrameMS(frameMS);
1609 1677
1610 // if (Frame%m_update_avatars == 0) 1678 // if (Frame%m_update_avatars == 0)
1611 // UpdateInWorldTime(); 1679 // UpdateInWorldTime();
1612 StatsReporter.AddPhysicsFPS(physicsFPS);
1613 StatsReporter.AddTimeDilation(TimeDilation);
1614 StatsReporter.AddFPS(1);
1615 1680
1616 StatsReporter.addFrameMS(frameMS);
1617 StatsReporter.addAgentMS(agentMS);
1618 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1619 StatsReporter.addOtherMS(otherMS);
1620 StatsReporter.AddSpareMS(spareMS);
1621 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1622 1681
1623 // Optionally warn if a frame takes double the amount of time that it should. 1682 // Optionally warn if a frame takes double the amount of time that it should.
1624 if (DebugUpdates 1683 if (DebugUpdates
@@ -1646,9 +1705,9 @@ namespace OpenSim.Region.Framework.Scenes
1646 1705
1647 private void CheckAtTargets() 1706 private void CheckAtTargets()
1648 { 1707 {
1649 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1708 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1650 lock (m_groupsWithTargets) 1709 lock (m_groupsWithTargets)
1651 objs = m_groupsWithTargets.Values; 1710 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1652 1711
1653 foreach (SceneObjectGroup entry in objs) 1712 foreach (SceneObjectGroup entry in objs)
1654 entry.checkAtTargets(); 1713 entry.checkAtTargets();
@@ -1729,7 +1788,7 @@ namespace OpenSim.Region.Framework.Scenes
1729 msg.fromAgentName = "Server"; 1788 msg.fromAgentName = "Server";
1730 msg.dialog = (byte)19; // Object msg 1789 msg.dialog = (byte)19; // Object msg
1731 msg.fromGroup = false; 1790 msg.fromGroup = false;
1732 msg.offline = (byte)0; 1791 msg.offline = (byte)1;
1733 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1792 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1734 msg.Position = Vector3.Zero; 1793 msg.Position = Vector3.Zero;
1735 msg.RegionID = RegionInfo.RegionID.Guid; 1794 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1951,6 +2010,19 @@ namespace OpenSim.Region.Framework.Scenes
1951 EventManager.TriggerPrimsLoaded(this); 2010 EventManager.TriggerPrimsLoaded(this);
1952 } 2011 }
1953 2012
2013 public bool SuportsRayCastFiltered()
2014 {
2015 if (PhysicsScene == null)
2016 return false;
2017 return PhysicsScene.SuportsRaycastWorldFiltered();
2018 }
2019
2020 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2021 {
2022 if (PhysicsScene == null)
2023 return null;
2024 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
2025 }
1954 2026
1955 /// <summary> 2027 /// <summary>
1956 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 2028 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1967,14 +2039,24 @@ namespace OpenSim.Region.Framework.Scenes
1967 /// <returns></returns> 2039 /// <returns></returns>
1968 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2040 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1969 { 2041 {
2042
2043 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2044 Vector3 wpos = Vector3.Zero;
2045 // Check for water surface intersection from above
2046 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2047 {
2048 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2049 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2050 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2051 wpos.Z = wheight;
2052 }
2053
1970 Vector3 pos = Vector3.Zero; 2054 Vector3 pos = Vector3.Zero;
1971 if (RayEndIsIntersection == (byte)1) 2055 if (RayEndIsIntersection == (byte)1)
1972 { 2056 {
1973 pos = RayEnd; 2057 pos = RayEnd;
1974 return pos;
1975 } 2058 }
1976 2059 else if (RayTargetID != UUID.Zero)
1977 if (RayTargetID != UUID.Zero)
1978 { 2060 {
1979 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2061 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1980 2062
@@ -1996,7 +2078,7 @@ namespace OpenSim.Region.Framework.Scenes
1996 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2078 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1997 2079
1998 // Un-comment out the following line to Get Raytrace results printed to the console. 2080 // Un-comment out the following line to Get Raytrace results printed to the console.
1999 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2081 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2000 float ScaleOffset = 0.5f; 2082 float ScaleOffset = 0.5f;
2001 2083
2002 // If we hit something 2084 // If we hit something
@@ -2019,13 +2101,10 @@ namespace OpenSim.Region.Framework.Scenes
2019 //pos.Z -= 0.25F; 2101 //pos.Z -= 0.25F;
2020 2102
2021 } 2103 }
2022
2023 return pos;
2024 } 2104 }
2025 else 2105 else
2026 { 2106 {
2027 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2107 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2028
2029 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2108 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2030 2109
2031 // Un-comment the following line to print the raytrace results to the console. 2110 // Un-comment the following line to print the raytrace results to the console.
@@ -2034,13 +2113,12 @@ namespace OpenSim.Region.Framework.Scenes
2034 if (ei.HitTF) 2113 if (ei.HitTF)
2035 { 2114 {
2036 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2115 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2037 } else 2116 }
2117 else
2038 { 2118 {
2039 // fall back to our stupid functionality 2119 // fall back to our stupid functionality
2040 pos = RayEnd; 2120 pos = RayEnd;
2041 } 2121 }
2042
2043 return pos;
2044 } 2122 }
2045 } 2123 }
2046 else 2124 else
@@ -2051,8 +2129,12 @@ namespace OpenSim.Region.Framework.Scenes
2051 //increase height so its above the ground. 2129 //increase height so its above the ground.
2052 //should be getting the normal of the ground at the rez point and using that? 2130 //should be getting the normal of the ground at the rez point and using that?
2053 pos.Z += scale.Z / 2f; 2131 pos.Z += scale.Z / 2f;
2054 return pos; 2132// return pos;
2055 } 2133 }
2134
2135 // check against posible water intercept
2136 if (wpos.Z > pos.Z) pos = wpos;
2137 return pos;
2056 } 2138 }
2057 2139
2058 2140
@@ -2141,7 +2223,10 @@ namespace OpenSim.Region.Framework.Scenes
2141 public bool AddRestoredSceneObject( 2223 public bool AddRestoredSceneObject(
2142 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2224 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2143 { 2225 {
2144 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2226 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2227 if (result)
2228 sceneObject.IsDeleted = false;
2229 return result;
2145 } 2230 }
2146 2231
2147 /// <summary> 2232 /// <summary>
@@ -2233,6 +2318,15 @@ namespace OpenSim.Region.Framework.Scenes
2233 /// </summary> 2318 /// </summary>
2234 public void DeleteAllSceneObjects() 2319 public void DeleteAllSceneObjects()
2235 { 2320 {
2321 DeleteAllSceneObjects(false);
2322 }
2323
2324 /// <summary>
2325 /// Delete every object from the scene. This does not include attachments worn by avatars.
2326 /// </summary>
2327 public void DeleteAllSceneObjects(bool exceptNoCopy)
2328 {
2329 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2236 lock (Entities) 2330 lock (Entities)
2237 { 2331 {
2238 EntityBase[] entities = Entities.GetEntities(); 2332 EntityBase[] entities = Entities.GetEntities();
@@ -2241,11 +2335,24 @@ namespace OpenSim.Region.Framework.Scenes
2241 if (e is SceneObjectGroup) 2335 if (e is SceneObjectGroup)
2242 { 2336 {
2243 SceneObjectGroup sog = (SceneObjectGroup)e; 2337 SceneObjectGroup sog = (SceneObjectGroup)e;
2244 if (!sog.IsAttachment) 2338 if (sog != null && !sog.IsAttachment)
2245 DeleteSceneObject((SceneObjectGroup)e, false); 2339 {
2340 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2341 {
2342 DeleteSceneObject((SceneObjectGroup)e, false);
2343 }
2344 else
2345 {
2346 toReturn.Add((SceneObjectGroup)e);
2347 }
2348 }
2246 } 2349 }
2247 } 2350 }
2248 } 2351 }
2352 if (toReturn.Count > 0)
2353 {
2354 returnObjects(toReturn.ToArray(), UUID.Zero);
2355 }
2249 } 2356 }
2250 2357
2251 /// <summary> 2358 /// <summary>
@@ -2280,6 +2387,12 @@ namespace OpenSim.Region.Framework.Scenes
2280 2387
2281 foreach (SceneObjectPart part in partList) 2388 foreach (SceneObjectPart part in partList)
2282 { 2389 {
2390 if (part.KeyframeMotion != null)
2391 {
2392 part.KeyframeMotion.Delete();
2393 part.KeyframeMotion = null;
2394 }
2395
2283 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) 2396 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
2284 { 2397 {
2285 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? 2398 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
@@ -2297,6 +2410,8 @@ namespace OpenSim.Region.Framework.Scenes
2297 } 2410 }
2298 2411
2299 group.DeleteGroupFromScene(silent); 2412 group.DeleteGroupFromScene(silent);
2413 if (!silent)
2414 SendKillObject(new List<uint>() { group.LocalId });
2300 2415
2301// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2416// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2302 } 2417 }
@@ -2587,7 +2702,7 @@ namespace OpenSim.Region.Framework.Scenes
2587 // If the user is banned, we won't let any of their objects 2702 // If the user is banned, we won't let any of their objects
2588 // enter. Period. 2703 // enter. Period.
2589 // 2704 //
2590 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2705 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2591 { 2706 {
2592 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2707 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2593 return false; 2708 return false;
@@ -2595,6 +2710,8 @@ namespace OpenSim.Region.Framework.Scenes
2595 2710
2596 if (newPosition != Vector3.Zero) 2711 if (newPosition != Vector3.Zero)
2597 newObject.RootPart.GroupPosition = newPosition; 2712 newObject.RootPart.GroupPosition = newPosition;
2713 if (newObject.RootPart.KeyframeMotion != null)
2714 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2598 2715
2599 if (!AddSceneObject(newObject)) 2716 if (!AddSceneObject(newObject))
2600 { 2717 {
@@ -2639,6 +2756,23 @@ namespace OpenSim.Region.Framework.Scenes
2639 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2756 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2640 public bool AddSceneObject(SceneObjectGroup sceneObject) 2757 public bool AddSceneObject(SceneObjectGroup sceneObject)
2641 { 2758 {
2759 if (sceneObject.OwnerID == UUID.Zero)
2760 {
2761 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2762 return false;
2763 }
2764
2765 // If the user is banned, we won't let any of their objects
2766 // enter. Period.
2767 //
2768 int flags = GetUserFlags(sceneObject.OwnerID);
2769 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2770 {
2771 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2772
2773 return false;
2774 }
2775
2642 // Force allocation of new LocalId 2776 // Force allocation of new LocalId
2643 // 2777 //
2644 SceneObjectPart[] parts = sceneObject.Parts; 2778 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2672,16 +2806,27 @@ namespace OpenSim.Region.Framework.Scenes
2672 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2806 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2673 2807
2674 if (AttachmentsModule != null) 2808 if (AttachmentsModule != null)
2675 AttachmentsModule.AttachObject(sp, grp, 0, false, false); 2809 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false);
2676 } 2810 }
2677 else 2811 else
2678 { 2812 {
2813 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2679 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2814 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2680 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2815 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2681 } 2816 }
2817 if (sceneObject.OwnerID == UUID.Zero)
2818 {
2819 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2820 return false;
2821 }
2682 } 2822 }
2683 else 2823 else
2684 { 2824 {
2825 if (sceneObject.OwnerID == UUID.Zero)
2826 {
2827 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2828 return false;
2829 }
2685 AddRestoredSceneObject(sceneObject, true, false); 2830 AddRestoredSceneObject(sceneObject, true, false);
2686 } 2831 }
2687 2832
@@ -2698,6 +2843,24 @@ namespace OpenSim.Region.Framework.Scenes
2698 return 2; // StateSource.PrimCrossing 2843 return 2; // StateSource.PrimCrossing
2699 } 2844 }
2700 2845
2846 public int GetUserFlags(UUID user)
2847 {
2848 //Unfortunately the SP approach means that the value is cached until region is restarted
2849 /*
2850 ScenePresence sp;
2851 if (TryGetScenePresence(user, out sp))
2852 {
2853 return sp.UserFlags;
2854 }
2855 else
2856 {
2857 */
2858 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2859 if (uac == null)
2860 return 0;
2861 return uac.UserFlags;
2862 //}
2863 }
2701 #endregion 2864 #endregion
2702 2865
2703 #region Add/Remove Avatar Methods 2866 #region Add/Remove Avatar Methods
@@ -2711,7 +2874,7 @@ namespace OpenSim.Region.Framework.Scenes
2711 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2874 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2712 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2875 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2713 2876
2714// CheckHeartbeat(); 2877 CheckHeartbeat();
2715 2878
2716 ScenePresence sp = GetScenePresence(client.AgentId); 2879 ScenePresence sp = GetScenePresence(client.AgentId);
2717 2880
@@ -2765,7 +2928,15 @@ namespace OpenSim.Region.Framework.Scenes
2765 2928
2766 EventManager.TriggerOnNewClient(client); 2929 EventManager.TriggerOnNewClient(client);
2767 if (vialogin) 2930 if (vialogin)
2931 {
2768 EventManager.TriggerOnClientLogin(client); 2932 EventManager.TriggerOnClientLogin(client);
2933 // Send initial parcel data
2934/* this is done on TriggerOnNewClient by landmanegement respective event handler
2935 Vector3 pos = sp.AbsolutePosition;
2936 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2937 land.SendLandUpdateToClient(client);
2938*/
2939 }
2769 2940
2770 return sp; 2941 return sp;
2771 } 2942 }
@@ -2854,19 +3025,14 @@ namespace OpenSim.Region.Framework.Scenes
2854 // and the scene presence and the client, if they exist 3025 // and the scene presence and the client, if they exist
2855 try 3026 try
2856 { 3027 {
2857 // We need to wait for the client to make UDP contact first. 3028 ScenePresence sp = GetScenePresence(agentID);
2858 // It's the UDP contact that creates the scene presence 3029
2859 ScenePresence sp = WaitGetScenePresence(agentID);
2860 if (sp != null) 3030 if (sp != null)
2861 { 3031 {
2862 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3032 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2863
2864 sp.ControllingClient.Close(); 3033 sp.ControllingClient.Close();
2865 } 3034 }
2866 else 3035
2867 {
2868 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2869 }
2870 // BANG! SLASH! 3036 // BANG! SLASH!
2871 m_authenticateHandler.RemoveCircuit(agentID); 3037 m_authenticateHandler.RemoveCircuit(agentID);
2872 3038
@@ -2911,6 +3077,8 @@ namespace OpenSim.Region.Framework.Scenes
2911 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3077 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2912 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3078 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2913 3079
3080 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3081
2914 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3082 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2915 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3083 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2916 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3084 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2967,6 +3135,7 @@ namespace OpenSim.Region.Framework.Scenes
2967 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3135 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2968 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3136 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2969 client.OnCopyInventoryItem += CopyInventoryItem; 3137 client.OnCopyInventoryItem += CopyInventoryItem;
3138 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2970 client.OnMoveInventoryItem += MoveInventoryItem; 3139 client.OnMoveInventoryItem += MoveInventoryItem;
2971 client.OnRemoveInventoryItem += RemoveInventoryItem; 3140 client.OnRemoveInventoryItem += RemoveInventoryItem;
2972 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3141 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3038,6 +3207,8 @@ namespace OpenSim.Region.Framework.Scenes
3038 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3207 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3039 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3208 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3040 3209
3210 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3211
3041 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3212 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3042 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3213 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3043 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3214 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3140,7 +3311,7 @@ namespace OpenSim.Region.Framework.Scenes
3140 /// </summary> 3311 /// </summary>
3141 /// <param name="agentId">The avatar's Unique ID</param> 3312 /// <param name="agentId">The avatar's Unique ID</param>
3142 /// <param name="client">The IClientAPI for the client</param> 3313 /// <param name="client">The IClientAPI for the client</param>
3143 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3314 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3144 { 3315 {
3145 if (EntityTransferModule != null) 3316 if (EntityTransferModule != null)
3146 { 3317 {
@@ -3151,6 +3322,7 @@ namespace OpenSim.Region.Framework.Scenes
3151 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3322 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3152 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3323 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3153 } 3324 }
3325 return false;
3154 } 3326 }
3155 3327
3156 /// <summary> 3328 /// <summary>
@@ -3260,6 +3432,16 @@ namespace OpenSim.Region.Framework.Scenes
3260 /// <param name="flags"></param> 3432 /// <param name="flags"></param>
3261 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3433 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3262 { 3434 {
3435 //Add half the avatar's height so that the user doesn't fall through prims
3436 ScenePresence presence;
3437 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3438 {
3439 if (presence.Appearance != null)
3440 {
3441 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3442 }
3443 }
3444
3263 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3445 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3264 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3446 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3265 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3447 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3376,6 +3558,7 @@ namespace OpenSim.Region.Framework.Scenes
3376 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3558 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3377 3559
3378 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3560 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3561 m_log.Debug("[Scene] The avatar has left the building");
3379 } 3562 }
3380 catch (Exception e) 3563 catch (Exception e)
3381 { 3564 {
@@ -3573,17 +3756,20 @@ namespace OpenSim.Region.Framework.Scenes
3573 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3756 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3574 sp.Name, sp.UUID, RegionInfo.RegionName); 3757 sp.Name, sp.UUID, RegionInfo.RegionName);
3575 3758
3576 sp.ControllingClient.Close(true); 3759 sp.ControllingClient.Close(true, true);
3577 sp = null; 3760 sp = null;
3578 } 3761 }
3579 3762
3580 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3581 3763
3582 //On login test land permisions 3764 //On login test land permisions
3583 if (vialogin) 3765 if (vialogin)
3584 { 3766 {
3585 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3767 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3768 if (cache != null)
3769 cache.Remove(agent.firstname + " " + agent.lastname);
3770 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3586 { 3771 {
3772 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3587 return false; 3773 return false;
3588 } 3774 }
3589 } 3775 }
@@ -3606,9 +3792,15 @@ namespace OpenSim.Region.Framework.Scenes
3606 3792
3607 try 3793 try
3608 { 3794 {
3609 if (!AuthorizeUser(agent, out reason)) 3795 // Always check estate if this is a login. Always
3610 return false; 3796 // check if banned regions are to be blacked out.
3611 } catch (Exception e) 3797 if (vialogin || (!m_seeIntoBannedRegion))
3798 {
3799 if (!AuthorizeUser(agent, out reason))
3800 return false;
3801 }
3802 }
3803 catch (Exception e)
3612 { 3804 {
3613 m_log.ErrorFormat( 3805 m_log.ErrorFormat(
3614 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3806 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@@ -3739,6 +3931,8 @@ namespace OpenSim.Region.Framework.Scenes
3739 } 3931 }
3740 3932
3741 // Honor parcel landing type and position. 3933 // Honor parcel landing type and position.
3934 /*
3935 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3742 if (land != null) 3936 if (land != null)
3743 { 3937 {
3744 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3938 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3746,25 +3940,43 @@ namespace OpenSim.Region.Framework.Scenes
3746 agent.startpos = land.LandData.UserLocation; 3940 agent.startpos = land.LandData.UserLocation;
3747 } 3941 }
3748 } 3942 }
3943 */// This is now handled properly in ScenePresence.MakeRootAgent
3749 } 3944 }
3750 3945
3751 return true; 3946 return true;
3752 } 3947 }
3753 3948
3754 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3949 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3755 { 3950 {
3756 bool banned = land.IsBannedFromLand(agent.AgentID); 3951 if (posX < 0)
3757 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3952 posX = 0;
3953 else if (posX >= 256)
3954 posX = 255.999f;
3955 if (posY < 0)
3956 posY = 0;
3957 else if (posY >= 256)
3958 posY = 255.999f;
3959
3960 reason = String.Empty;
3961 if (Permissions.IsGod(agentID))
3962 return true;
3963
3964 ILandObject land = LandChannel.GetLandObject(posX, posY);
3965 if (land == null)
3966 return false;
3967
3968 bool banned = land.IsBannedFromLand(agentID);
3969 bool restricted = land.IsRestrictedFromLand(agentID);
3758 3970
3759 if (banned || restricted) 3971 if (banned || restricted)
3760 { 3972 {
3761 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3973 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3762 if (nearestParcel != null) 3974 if (nearestParcel != null)
3763 { 3975 {
3764 //Move agent to nearest allowed 3976 //Move agent to nearest allowed
3765 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3977 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3766 agent.startpos.X = newPosition.X; 3978 posX = newPosition.X;
3767 agent.startpos.Y = newPosition.Y; 3979 posY = newPosition.Y;
3768 } 3980 }
3769 else 3981 else
3770 { 3982 {
@@ -3826,7 +4038,7 @@ namespace OpenSim.Region.Framework.Scenes
3826 4038
3827 if (!m_strictAccessControl) return true; 4039 if (!m_strictAccessControl) return true;
3828 if (Permissions.IsGod(agent.AgentID)) return true; 4040 if (Permissions.IsGod(agent.AgentID)) return true;
3829 4041
3830 if (AuthorizationService != null) 4042 if (AuthorizationService != null)
3831 { 4043 {
3832 if (!AuthorizationService.IsAuthorizedForRegion( 4044 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3841,7 +4053,7 @@ namespace OpenSim.Region.Framework.Scenes
3841 4053
3842 if (RegionInfo.EstateSettings != null) 4054 if (RegionInfo.EstateSettings != null)
3843 { 4055 {
3844 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4056 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3845 { 4057 {
3846 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4058 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3847 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4059 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4031,6 +4243,15 @@ namespace OpenSim.Region.Framework.Scenes
4031 4243
4032 // XPTO: if this agent is not allowed here as root, always return false 4244 // XPTO: if this agent is not allowed here as root, always return false
4033 4245
4246 // We have to wait until the viewer contacts this region after receiving EAC.
4247 // That calls AddNewClient, which finally creates the ScenePresence
4248 int flags = GetUserFlags(cAgentData.AgentID);
4249 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4250 {
4251 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4252 return false;
4253 }
4254
4034 // TODO: This check should probably be in QueryAccess(). 4255 // TODO: This check should probably be in QueryAccess().
4035 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4256 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4036 if (nearestParcel == null) 4257 if (nearestParcel == null)
@@ -4094,7 +4315,7 @@ namespace OpenSim.Region.Framework.Scenes
4094 /// <param name='agentID'></param> 4315 /// <param name='agentID'></param>
4095 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4316 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4096 { 4317 {
4097 int ntimes = 10; 4318 int ntimes = 20;
4098 ScenePresence sp = null; 4319 ScenePresence sp = null;
4099 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4320 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4100 Thread.Sleep(1000); 4321 Thread.Sleep(1000);
@@ -4124,6 +4345,16 @@ namespace OpenSim.Region.Framework.Scenes
4124 return false; 4345 return false;
4125 } 4346 }
4126 4347
4348 public bool IncomingCloseAgent(UUID agentID)
4349 {
4350 return IncomingCloseAgent(agentID, false);
4351 }
4352
4353 public bool IncomingCloseChildAgent(UUID agentID)
4354 {
4355 return IncomingCloseAgent(agentID, true);
4356 }
4357
4127 /// <summary> 4358 /// <summary>
4128 /// Tell a single agent to disconnect from the region. 4359 /// Tell a single agent to disconnect from the region.
4129 /// </summary> 4360 /// </summary>
@@ -4139,7 +4370,7 @@ namespace OpenSim.Region.Framework.Scenes
4139 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4370 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4140 if (presence != null) 4371 if (presence != null)
4141 { 4372 {
4142 presence.ControllingClient.Close(force); 4373 presence.ControllingClient.Close(true, force);
4143 return true; 4374 return true;
4144 } 4375 }
4145 4376
@@ -4787,35 +5018,81 @@ namespace OpenSim.Region.Framework.Scenes
4787 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5018 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4788 } 5019 }
4789 5020
4790 public int GetHealth() 5021 public int GetHealth(out int flags, out string message)
4791 { 5022 {
4792 // Returns: 5023 // Returns:
4793 // 1 = sim is up and accepting http requests. The heartbeat has 5024 // 1 = sim is up and accepting http requests. The heartbeat has
4794 // stopped and the sim is probably locked up, but a remote 5025 // stopped and the sim is probably locked up, but a remote
4795 // admin restart may succeed 5026 // admin restart may succeed
4796 // 5027 //
4797 // 2 = Sim is up and the heartbeat is running. The sim is likely 5028 // 2 = Sim is up and the heartbeat is running. The sim is likely
4798 // usable for people within and logins _may_ work 5029 // usable for people within
5030 //
5031 // 3 = Sim is up and one packet thread is running. Sim is
5032 // unstable and will not accept new logins
4799 // 5033 //
4800 // 3 = We have seen a new user enter within the past 4 minutes 5034 // 4 = Sim is up and both packet threads are running. Sim is
5035 // likely usable
5036 //
5037 // 5 = We have seen a new user enter within the past 4 minutes
4801 // which can be seen as positive confirmation of sim health 5038 // which can be seen as positive confirmation of sim health
4802 // 5039 //
5040
5041 flags = 0;
5042 message = String.Empty;
5043
5044 CheckHeartbeat();
5045
5046 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5047 {
5048 // We're still starting
5049 // 0 means "in startup", it can't happen another way, since
5050 // to get here, we must be able to accept http connections
5051 return 0;
5052 }
5053
4803 int health=1; // Start at 1, means we're up 5054 int health=1; // Start at 1, means we're up
4804 5055
4805 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5056 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4806 health += 1; 5057 {
5058 health+=1;
5059 flags |= 1;
5060 }
5061
5062 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5063 {
5064 health+=1;
5065 flags |= 2;
5066 }
5067
5068 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5069 {
5070 health+=1;
5071 flags |= 4;
5072 }
4807 else 5073 else
5074 {
5075int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5076System.Diagnostics.Process proc = new System.Diagnostics.Process();
5077proc.EnableRaisingEvents=false;
5078proc.StartInfo.FileName = "/bin/kill";
5079proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5080proc.Start();
5081proc.WaitForExit();
5082Thread.Sleep(1000);
5083Environment.Exit(1);
5084 }
5085
5086 if (flags != 7)
4808 return health; 5087 return health;
4809 5088
4810 // A login in the last 4 mins? We can't be doing too badly 5089 // A login in the last 4 mins? We can't be doing too badly
4811 // 5090 //
4812 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5091 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4813 health++; 5092 health++;
4814 else 5093 else
4815 return health; 5094 return health;
4816 5095
4817// CheckHeartbeat();
4818
4819 return health; 5096 return health;
4820 } 5097 }
4821 5098
@@ -4903,7 +5180,7 @@ namespace OpenSim.Region.Framework.Scenes
4903 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5180 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4904 if (wasUsingPhysics) 5181 if (wasUsingPhysics)
4905 { 5182 {
4906 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 5183 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
4907 } 5184 }
4908 } 5185 }
4909 5186
@@ -5002,14 +5279,14 @@ namespace OpenSim.Region.Framework.Scenes
5002 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5279 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5003 } 5280 }
5004 5281
5005// private void CheckHeartbeat() 5282 private void CheckHeartbeat()
5006// { 5283 {
5007// if (m_firstHeartbeat) 5284 if (m_firstHeartbeat)
5008// return; 5285 return;
5009// 5286
5010// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5287 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5011// StartTimer(); 5288 Start();
5012// } 5289 }
5013 5290
5014 public override ISceneObject DeserializeObject(string representation) 5291 public override ISceneObject DeserializeObject(string representation)
5015 { 5292 {
@@ -5021,9 +5298,14 @@ namespace OpenSim.Region.Framework.Scenes
5021 get { return m_allowScriptCrossings; } 5298 get { return m_allowScriptCrossings; }
5022 } 5299 }
5023 5300
5024 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5301 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5302 {
5303 return GetNearestAllowedPosition(avatar, null);
5304 }
5305
5306 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5025 { 5307 {
5026 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5308 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
5027 5309
5028 if (nearestParcel != null) 5310 if (nearestParcel != null)
5029 { 5311 {
@@ -5032,10 +5314,7 @@ namespace OpenSim.Region.Framework.Scenes
5032 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5314 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5033 if (nearestPoint != null) 5315 if (nearestPoint != null)
5034 { 5316 {
5035// m_log.DebugFormat( 5317 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
5036// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
5037// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
5038
5039 return nearestPoint.Value; 5318 return nearestPoint.Value;
5040 } 5319 }
5041 5320
@@ -5045,17 +5324,20 @@ namespace OpenSim.Region.Framework.Scenes
5045 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5324 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5046 if (nearestPoint != null) 5325 if (nearestPoint != null)
5047 { 5326 {
5048// m_log.DebugFormat( 5327 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5049// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
5050
5051 return nearestPoint.Value; 5328 return nearestPoint.Value;
5052 } 5329 }
5053 5330
5054 //Ultimate backup if we have no idea where they are 5331 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5055// m_log.DebugFormat( 5332 if (dest != excludeParcel)
5056// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5333 {
5334 // Ultimate backup if we have no idea where they are and
5335 // the last allowed position was in another parcel
5336 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5337 return avatar.lastKnownAllowedPosition;
5338 }
5057 5339
5058 return avatar.lastKnownAllowedPosition; 5340 // else fall through to region edge
5059 } 5341 }
5060 5342
5061 //Go to the edge, this happens in teleporting to a region with no available parcels 5343 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -5089,13 +5371,18 @@ namespace OpenSim.Region.Framework.Scenes
5089 5371
5090 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5372 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5091 { 5373 {
5374 return GetNearestAllowedParcel(avatarId, x, y, null);
5375 }
5376
5377 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5378 {
5092 List<ILandObject> all = AllParcels(); 5379 List<ILandObject> all = AllParcels();
5093 float minParcelDistance = float.MaxValue; 5380 float minParcelDistance = float.MaxValue;
5094 ILandObject nearestParcel = null; 5381 ILandObject nearestParcel = null;
5095 5382
5096 foreach (var parcel in all) 5383 foreach (var parcel in all)
5097 { 5384 {
5098 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5385 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5099 { 5386 {
5100 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5387 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5101 if (parcelDistance < minParcelDistance) 5388 if (parcelDistance < minParcelDistance)
@@ -5337,7 +5624,55 @@ namespace OpenSim.Region.Framework.Scenes
5337 mapModule.GenerateMaptile(); 5624 mapModule.GenerateMaptile();
5338 } 5625 }
5339 5626
5340 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5627// public void CleanDroppedAttachments()
5628// {
5629// List<SceneObjectGroup> objectsToDelete =
5630// new List<SceneObjectGroup>();
5631//
5632// lock (m_cleaningAttachments)
5633// {
5634// ForEachSOG(delegate (SceneObjectGroup grp)
5635// {
5636// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5637// {
5638// UUID agentID = grp.OwnerID;
5639// if (agentID == UUID.Zero)
5640// {
5641// objectsToDelete.Add(grp);
5642// return;
5643// }
5644//
5645// ScenePresence sp = GetScenePresence(agentID);
5646// if (sp == null)
5647// {
5648// objectsToDelete.Add(grp);
5649// return;
5650// }
5651// }
5652// });
5653// }
5654//
5655// foreach (SceneObjectGroup grp in objectsToDelete)
5656// {
5657// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5658// DeleteSceneObject(grp, true);
5659// }
5660// }
5661
5662 public void ThreadAlive(int threadCode)
5663 {
5664 switch(threadCode)
5665 {
5666 case 1: // Incoming
5667 m_lastIncoming = Util.EnvironmentTickCount();
5668 break;
5669 case 2: // Incoming
5670 m_lastOutgoing = Util.EnvironmentTickCount();
5671 break;
5672 }
5673 }
5674
5675 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5341 { 5676 {
5342 RegenerateMaptile(); 5677 RegenerateMaptile();
5343 5678
@@ -5365,6 +5700,8 @@ namespace OpenSim.Region.Framework.Scenes
5365 /// <returns></returns> 5700 /// <returns></returns>
5366 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5701 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5367 { 5702 {
5703 reason = "You are banned from the region";
5704
5368 if (EntityTransferModule.IsInTransit(agentID)) 5705 if (EntityTransferModule.IsInTransit(agentID))
5369 { 5706 {
5370 reason = "Agent is still in transit from this region"; 5707 reason = "Agent is still in transit from this region";
@@ -5376,6 +5713,12 @@ namespace OpenSim.Region.Framework.Scenes
5376 return false; 5713 return false;
5377 } 5714 }
5378 5715
5716 if (Permissions.IsGod(agentID))
5717 {
5718 reason = String.Empty;
5719 return true;
5720 }
5721
5379 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5722 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5380 // However, the long term fix is to make sure root agent count is always accurate. 5723 // However, the long term fix is to make sure root agent count is always accurate.
5381 m_sceneGraph.RecalculateStats(); 5724 m_sceneGraph.RecalculateStats();
@@ -5396,6 +5739,41 @@ namespace OpenSim.Region.Framework.Scenes
5396 } 5739 }
5397 } 5740 }
5398 5741
5742 ScenePresence presence = GetScenePresence(agentID);
5743 IClientAPI client = null;
5744 AgentCircuitData aCircuit = null;
5745
5746 if (presence != null)
5747 {
5748 client = presence.ControllingClient;
5749 if (client != null)
5750 aCircuit = client.RequestClientInfo();
5751 }
5752
5753 // We may be called before there is a presence or a client.
5754 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5755 if (client == null)
5756 {
5757 aCircuit = new AgentCircuitData();
5758 aCircuit.AgentID = agentID;
5759 aCircuit.firstname = String.Empty;
5760 aCircuit.lastname = String.Empty;
5761 }
5762
5763 try
5764 {
5765 if (!AuthorizeUser(aCircuit, out reason))
5766 {
5767 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5768 return false;
5769 }
5770 }
5771 catch (Exception e)
5772 {
5773 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5774 return false;
5775 }
5776
5399 if (position == Vector3.Zero) // Teleport 5777 if (position == Vector3.Zero) // Teleport
5400 { 5778 {
5401 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5779 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5424,13 +5802,46 @@ namespace OpenSim.Region.Framework.Scenes
5424 } 5802 }
5425 } 5803 }
5426 } 5804 }
5805
5806 float posX = 128.0f;
5807 float posY = 128.0f;
5808
5809 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5810 {
5811 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5812 return false;
5813 }
5814 }
5815 else // Walking
5816 {
5817 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5818 if (land == null)
5819 return false;
5820
5821 bool banned = land.IsBannedFromLand(agentID);
5822 bool restricted = land.IsRestrictedFromLand(agentID);
5823
5824 if (banned || restricted)
5825 return false;
5427 } 5826 }
5428 5827
5429 reason = String.Empty; 5828 reason = String.Empty;
5430 return true; 5829 return true;
5431 } 5830 }
5432 5831
5433 /// <summary> 5832 public void StartTimerWatchdog()
5833 {
5834 m_timerWatchdog.Interval = 1000;
5835 m_timerWatchdog.Elapsed += TimerWatchdog;
5836 m_timerWatchdog.AutoReset = true;
5837 m_timerWatchdog.Start();
5838 }
5839
5840 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5841 {
5842 CheckHeartbeat();
5843 }
5844
5434 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5845 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5435 /// autopilot that moves an avatar to a sit target!. 5846 /// autopilot that moves an avatar to a sit target!.
5436 /// </summary> 5847 /// </summary>
@@ -5509,6 +5920,11 @@ namespace OpenSim.Region.Framework.Scenes
5509 return m_SpawnPoint - 1; 5920 return m_SpawnPoint - 1;
5510 } 5921 }
5511 5922
5923 private void HandleGcCollect(string module, string[] args)
5924 {
5925 GC.Collect();
5926 }
5927
5512 // Wrappers to get physics modules retrieve assets. Has to be done this way 5928 // Wrappers to get physics modules retrieve assets. Has to be done this way
5513 // because we can't assign the asset service to physics directly - at the 5929 // because we can't assign the asset service to physics directly - at the
5514 // time physics are instantiated it's not registered but it will be by 5930 // time physics are instantiated it's not registered but it will be by