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.cs835
1 files changed, 624 insertions, 211 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2e03874..129bf09 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -151,8 +151,8 @@ 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 154 public bool m_seeIntoBannedRegion = false;
155 public int MaxUndoCount { get; set; } 155 public int MaxUndoCount = 5;
156 156
157 // 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;
158 public bool LoginLock = false; 158 public bool LoginLock = false;
@@ -168,12 +168,14 @@ namespace OpenSim.Region.Framework.Scenes
168 168
169 protected int m_splitRegionID; 169 protected int m_splitRegionID;
170 protected Timer m_restartWaitTimer = new Timer(); 170 protected Timer m_restartWaitTimer = new Timer();
171 protected Timer m_timerWatchdog = new Timer();
171 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 172 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
172 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 173 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
173 protected string m_simulatorVersion = "OpenSimulator Server"; 174 protected string m_simulatorVersion = "OpenSimulator Server";
174 protected ModuleLoader m_moduleLoader; 175 protected ModuleLoader m_moduleLoader;
175 protected AgentCircuitManager m_authenticateHandler; 176 protected AgentCircuitManager m_authenticateHandler;
176 protected SceneCommunicationService m_sceneGridService; 177 protected SceneCommunicationService m_sceneGridService;
178 protected ISnmpModule m_snmpService = null;
177 179
178 protected ISimulationDataService m_SimulationDataService; 180 protected ISimulationDataService m_SimulationDataService;
179 protected IEstateDataService m_EstateDataService; 181 protected IEstateDataService m_EstateDataService;
@@ -236,8 +238,8 @@ namespace OpenSim.Region.Framework.Scenes
236 private int m_update_presences = 1; // Update scene presence movements 238 private int m_update_presences = 1; // Update scene presence movements
237 private int m_update_events = 1; 239 private int m_update_events = 1;
238 private int m_update_backup = 200; 240 private int m_update_backup = 200;
239 private int m_update_terrain = 50; 241 private int m_update_terrain = 1000;
240// private int m_update_land = 1; 242 private int m_update_land = 10;
241 private int m_update_coarse_locations = 50; 243 private int m_update_coarse_locations = 50;
242 244
243 private int agentMS; 245 private int agentMS;
@@ -250,13 +252,13 @@ namespace OpenSim.Region.Framework.Scenes
250 private int backupMS; 252 private int backupMS;
251 private int terrainMS; 253 private int terrainMS;
252 private int landMS; 254 private int landMS;
253 private int spareMS;
254 255
255 /// <summary> 256 /// <summary>
256 /// Tick at which the last frame was processed. 257 /// Tick at which the last frame was processed.
257 /// </summary> 258 /// </summary>
258 private int m_lastFrameTick; 259 private int m_lastFrameTick;
259 260
261 public bool CombineRegions = false;
260 /// <summary> 262 /// <summary>
261 /// Tick at which the last maintenance run occurred. 263 /// Tick at which the last maintenance run occurred.
262 /// </summary> 264 /// </summary>
@@ -287,6 +289,11 @@ namespace OpenSim.Region.Framework.Scenes
287 /// </summary> 289 /// </summary>
288 private int m_LastLogin; 290 private int m_LastLogin;
289 291
292 private int m_lastIncoming;
293 private int m_lastOutgoing;
294 private int m_hbRestarts = 0;
295
296
290 /// <summary> 297 /// <summary>
291 /// Thread that runs the scene loop. 298 /// Thread that runs the scene loop.
292 /// </summary> 299 /// </summary>
@@ -302,7 +309,7 @@ namespace OpenSim.Region.Framework.Scenes
302 private volatile bool m_shuttingDown; 309 private volatile bool m_shuttingDown;
303 310
304// private int m_lastUpdate; 311// private int m_lastUpdate;
305// private bool m_firstHeartbeat = true; 312 private bool m_firstHeartbeat = true;
306 313
307 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 314 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
308 private bool m_reprioritizationEnabled = true; 315 private bool m_reprioritizationEnabled = true;
@@ -347,6 +354,19 @@ namespace OpenSim.Region.Framework.Scenes
347 get { return m_sceneGridService; } 354 get { return m_sceneGridService; }
348 } 355 }
349 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
350 public ISimulationDataService SimulationDataService 370 public ISimulationDataService SimulationDataService
351 { 371 {
352 get 372 get
@@ -646,6 +666,8 @@ namespace OpenSim.Region.Framework.Scenes
646 m_SimulationDataService = simDataService; 666 m_SimulationDataService = simDataService;
647 m_EstateDataService = estateDataService; 667 m_EstateDataService = estateDataService;
648 m_regionHandle = RegionInfo.RegionHandle; 668 m_regionHandle = RegionInfo.RegionHandle;
669 m_lastIncoming = 0;
670 m_lastOutgoing = 0;
649 671
650 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 672 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
651 m_asyncSceneObjectDeleter.Enabled = true; 673 m_asyncSceneObjectDeleter.Enabled = true;
@@ -728,139 +750,148 @@ namespace OpenSim.Region.Framework.Scenes
728 750
729 // Region config overrides global config 751 // Region config overrides global config
730 // 752 //
731 if (m_config.Configs["Startup"] != null) 753 try
732 { 754 {
733 IConfig startupConfig = m_config.Configs["Startup"]; 755 if (m_config.Configs["Startup"] != null)
734 756 {
735 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 757 IConfig startupConfig = m_config.Configs["Startup"];
736
737 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
738 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
739 if (!m_useBackup)
740 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
741
742 //Animation states
743 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
744 758
745 MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); 759 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
746 760
747 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); 761 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
748 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);
749 768
750 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); 769 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
751 if (RegionInfo.NonphysPrimMin > 0) 770 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
752 {
753 m_minNonphys = RegionInfo.NonphysPrimMin;
754 }
755 771
756 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 772 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
757 if (RegionInfo.NonphysPrimMax > 0) 773 if (RegionInfo.NonphysPrimMin > 0)
758 { 774 {
759 m_maxNonphys = RegionInfo.NonphysPrimMax; 775 m_minNonphys = RegionInfo.NonphysPrimMin;
760 } 776 }
761 777
762 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); 778 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
763 if (RegionInfo.PhysPrimMin > 0) 779 if (RegionInfo.NonphysPrimMax > 0)
764 { 780 {
765 m_minPhys = RegionInfo.PhysPrimMin; 781 m_maxNonphys = RegionInfo.NonphysPrimMax;
766 } 782 }
767 783
768 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 784 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
769 if (RegionInfo.PhysPrimMax > 0) 785 if (RegionInfo.PhysPrimMin > 0)
770 { 786 {
771 m_maxPhys = RegionInfo.PhysPrimMax; 787 m_minPhys = RegionInfo.PhysPrimMin;
772 } 788 }
773 789
774 // Here, if clamping is requested in either global or 790 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
775 // local config, it will be used
776 //
777 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
778 if (RegionInfo.ClampPrimSize)
779 {
780 m_clampPrimSize = true;
781 }
782 791
783 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 792 if (RegionInfo.PhysPrimMax > 0)
784 if (RegionInfo.LinksetCapacity > 0) 793 {
785 { 794 m_maxPhys = RegionInfo.PhysPrimMax;
786 m_linksetCapacity = RegionInfo.LinksetCapacity; 795 }
787 }
788 796
789 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 797 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
790 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 798 if (RegionInfo.LinksetCapacity > 0)
791 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 799 {
792 m_dontPersistBefore = 800 m_linksetCapacity = RegionInfo.LinksetCapacity;
793 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); 801 }
794 m_dontPersistBefore *= 10000000;
795 m_persistAfter =
796 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
797 m_persistAfter *= 10000000;
798 802
799 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 803 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
804 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
800 805
801 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 806 // Here, if clamping is requested in either global or
802 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 }
803 814
804 IConfig packetConfig = m_config.Configs["PacketPool"]; 815 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
805 if (packetConfig != null) 816 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
806 { 817 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
807 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); 818 m_dontPersistBefore =
808 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); 819 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
809 } 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 }
810 834
811 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);
812 838
813 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 839 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
814 if (m_generateMaptiles) 840 if (m_generateMaptiles)
815 {
816 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
817 if (maptileRefresh != 0)
818 { 841 {
819 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 842 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
820 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; 843 if (maptileRefresh != 0)
821 m_mapGenerationTimer.AutoReset = true; 844 {
822 m_mapGenerationTimer.Start(); 845 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
846 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
847 m_mapGenerationTimer.AutoReset = true;
848 m_mapGenerationTimer.Start();
849 }
823 } 850 }
824 } 851 else
825 else
826 {
827 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
828 UUID tileID;
829
830 if (UUID.TryParse(tile, out tileID))
831 { 852 {
832 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 }
833 } 860 }
834 }
835 861
836 string grant = startupConfig.GetString("AllowedClients", String.Empty); 862 string grant = startupConfig.GetString("AllowedClients", String.Empty);
837 if (grant.Length > 0) 863 if (grant.Length > 0)
838 {
839 foreach (string viewer in grant.Split('|'))
840 { 864 {
841 m_AllowedViewers.Add(viewer.Trim().ToLower()); 865 foreach (string viewer in grant.Split(','))
866 {
867 m_AllowedViewers.Add(viewer.Trim().ToLower());
868 }
842 } 869 }
843 }
844 870
845 grant = startupConfig.GetString("BannedClients", String.Empty); 871 grant = startupConfig.GetString("BannedClients", String.Empty);
846 if (grant.Length > 0) 872 if (grant.Length > 0)
847 {
848 foreach (string viewer in grant.Split('|'))
849 { 873 {
850 m_BannedViewers.Add(viewer.Trim().ToLower()); 874 foreach (string viewer in grant.Split(','))
875 {
876 m_BannedViewers.Add(viewer.Trim().ToLower());
877 }
851 } 878 }
852 }
853 879
854 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 880 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
855 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 881 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
856 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 882 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
857 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 883 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
858 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 884 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
859 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); 885 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
860 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); 886 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
861 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); 887 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
862 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 888 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
863 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());
864 } 895 }
865 896
866 // FIXME: Ultimately this should be in a module. 897 // FIXME: Ultimately this should be in a module.
@@ -905,6 +936,8 @@ namespace OpenSim.Region.Framework.Scenes
905 StatsReporter = new SimStatsReporter(this); 936 StatsReporter = new SimStatsReporter(this);
906 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 937 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
907 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 938 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
939
940 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
908 } 941 }
909 942
910 public Scene(RegionInfo regInfo) : base(regInfo) 943 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1307,7 +1340,22 @@ namespace OpenSim.Region.Framework.Scenes
1307 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1340 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1308 if (m_heartbeatThread != null) 1341 if (m_heartbeatThread != null)
1309 { 1342 {
1343 m_hbRestarts++;
1344 if(m_hbRestarts > 10)
1345 Environment.Exit(1);
1346 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1347
1348//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1349//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1350//proc.EnableRaisingEvents=false;
1351//proc.StartInfo.FileName = "/bin/kill";
1352//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1353//proc.Start();
1354//proc.WaitForExit();
1355//Thread.Sleep(1000);
1356//Environment.Exit(1);
1310 m_heartbeatThread.Abort(); 1357 m_heartbeatThread.Abort();
1358 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1311 m_heartbeatThread = null; 1359 m_heartbeatThread = null;
1312 } 1360 }
1313// m_lastUpdate = Util.EnvironmentTickCount(); 1361// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1454,16 +1502,20 @@ namespace OpenSim.Region.Framework.Scenes
1454 endFrame = Frame + frames; 1502 endFrame = Frame + frames;
1455 1503
1456 float physicsFPS = 0f; 1504 float physicsFPS = 0f;
1457 int previousFrameTick, tmpMS; 1505 int tmpMS;
1458 int maintc = Util.EnvironmentTickCount(); 1506 int previousFrameTick;
1507 int maintc;
1508 int sleepMS;
1509 int framestart;
1459 1510
1460 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1511 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1461 { 1512 {
1513 framestart = Util.EnvironmentTickCount();
1462 ++Frame; 1514 ++Frame;
1463 1515
1464// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1516// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1465 1517
1466 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1518 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1467 1519
1468 try 1520 try
1469 { 1521 {
@@ -1515,6 +1567,7 @@ namespace OpenSim.Region.Framework.Scenes
1515 m_sceneGraph.UpdatePresences(); 1567 m_sceneGraph.UpdatePresences();
1516 1568
1517 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1569 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1570
1518 1571
1519 // Delete temp-on-rez stuff 1572 // Delete temp-on-rez stuff
1520 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1573 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1596,34 +1649,37 @@ namespace OpenSim.Region.Framework.Scenes
1596 1649
1597 Watchdog.UpdateThread(); 1650 Watchdog.UpdateThread();
1598 1651
1652 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1653
1654 StatsReporter.AddPhysicsFPS(physicsFPS);
1655 StatsReporter.AddTimeDilation(TimeDilation);
1656 StatsReporter.AddFPS(1);
1657
1658 StatsReporter.addAgentMS(agentMS);
1659 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1660 StatsReporter.addOtherMS(otherMS);
1661 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1662
1599 previousFrameTick = m_lastFrameTick; 1663 previousFrameTick = m_lastFrameTick;
1600 m_lastFrameTick = Util.EnvironmentTickCount(); 1664 m_lastFrameTick = Util.EnvironmentTickCount();
1601 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1665 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1602 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1666 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1603 1667
1668 m_firstHeartbeat = false;
1669
1670 sleepMS = Util.EnvironmentTickCount();
1671
1604 if (tmpMS > 0) 1672 if (tmpMS > 0)
1605 {
1606 Thread.Sleep(tmpMS); 1673 Thread.Sleep(tmpMS);
1607 spareMS += tmpMS;
1608 }
1609
1610 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1611 maintc = Util.EnvironmentTickCount();
1612 1674
1613 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1675 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1676 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1677 StatsReporter.addSleepMS(sleepMS);
1678 StatsReporter.addFrameMS(frameMS);
1614 1679
1615 // if (Frame%m_update_avatars == 0) 1680 // if (Frame%m_update_avatars == 0)
1616 // UpdateInWorldTime(); 1681 // UpdateInWorldTime();
1617 StatsReporter.AddPhysicsFPS(physicsFPS);
1618 StatsReporter.AddTimeDilation(TimeDilation);
1619 StatsReporter.AddFPS(1);
1620 1682
1621 StatsReporter.addFrameMS(frameMS);
1622 StatsReporter.addAgentMS(agentMS);
1623 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1624 StatsReporter.addOtherMS(otherMS);
1625 StatsReporter.AddSpareMS(spareMS);
1626 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1627 1683
1628 // Optionally warn if a frame takes double the amount of time that it should. 1684 // Optionally warn if a frame takes double the amount of time that it should.
1629 if (DebugUpdates 1685 if (DebugUpdates
@@ -1651,9 +1707,9 @@ namespace OpenSim.Region.Framework.Scenes
1651 1707
1652 private void CheckAtTargets() 1708 private void CheckAtTargets()
1653 { 1709 {
1654 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1710 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1655 lock (m_groupsWithTargets) 1711 lock (m_groupsWithTargets)
1656 objs = m_groupsWithTargets.Values; 1712 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1657 1713
1658 foreach (SceneObjectGroup entry in objs) 1714 foreach (SceneObjectGroup entry in objs)
1659 entry.checkAtTargets(); 1715 entry.checkAtTargets();
@@ -1734,7 +1790,7 @@ namespace OpenSim.Region.Framework.Scenes
1734 msg.fromAgentName = "Server"; 1790 msg.fromAgentName = "Server";
1735 msg.dialog = (byte)19; // Object msg 1791 msg.dialog = (byte)19; // Object msg
1736 msg.fromGroup = false; 1792 msg.fromGroup = false;
1737 msg.offline = (byte)0; 1793 msg.offline = (byte)1;
1738 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1794 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1739 msg.Position = Vector3.Zero; 1795 msg.Position = Vector3.Zero;
1740 msg.RegionID = RegionInfo.RegionID.Guid; 1796 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1956,6 +2012,19 @@ namespace OpenSim.Region.Framework.Scenes
1956 EventManager.TriggerPrimsLoaded(this); 2012 EventManager.TriggerPrimsLoaded(this);
1957 } 2013 }
1958 2014
2015 public bool SuportsRayCastFiltered()
2016 {
2017 if (PhysicsScene == null)
2018 return false;
2019 return PhysicsScene.SuportsRaycastWorldFiltered();
2020 }
2021
2022 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2023 {
2024 if (PhysicsScene == null)
2025 return null;
2026 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
2027 }
1959 2028
1960 /// <summary> 2029 /// <summary>
1961 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 2030 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1972,14 +2041,24 @@ namespace OpenSim.Region.Framework.Scenes
1972 /// <returns></returns> 2041 /// <returns></returns>
1973 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2042 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1974 { 2043 {
2044
2045 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2046 Vector3 wpos = Vector3.Zero;
2047 // Check for water surface intersection from above
2048 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2049 {
2050 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2051 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2052 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2053 wpos.Z = wheight;
2054 }
2055
1975 Vector3 pos = Vector3.Zero; 2056 Vector3 pos = Vector3.Zero;
1976 if (RayEndIsIntersection == (byte)1) 2057 if (RayEndIsIntersection == (byte)1)
1977 { 2058 {
1978 pos = RayEnd; 2059 pos = RayEnd;
1979 return pos;
1980 } 2060 }
1981 2061 else if (RayTargetID != UUID.Zero)
1982 if (RayTargetID != UUID.Zero)
1983 { 2062 {
1984 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2063 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1985 2064
@@ -2001,7 +2080,7 @@ namespace OpenSim.Region.Framework.Scenes
2001 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2080 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2002 2081
2003 // Un-comment out the following line to Get Raytrace results printed to the console. 2082 // Un-comment out the following line to Get Raytrace results printed to the console.
2004 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2083 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2005 float ScaleOffset = 0.5f; 2084 float ScaleOffset = 0.5f;
2006 2085
2007 // If we hit something 2086 // If we hit something
@@ -2024,13 +2103,10 @@ namespace OpenSim.Region.Framework.Scenes
2024 //pos.Z -= 0.25F; 2103 //pos.Z -= 0.25F;
2025 2104
2026 } 2105 }
2027
2028 return pos;
2029 } 2106 }
2030 else 2107 else
2031 { 2108 {
2032 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2109 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2033
2034 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2110 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2035 2111
2036 // Un-comment the following line to print the raytrace results to the console. 2112 // Un-comment the following line to print the raytrace results to the console.
@@ -2039,13 +2115,12 @@ namespace OpenSim.Region.Framework.Scenes
2039 if (ei.HitTF) 2115 if (ei.HitTF)
2040 { 2116 {
2041 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2117 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2042 } else 2118 }
2119 else
2043 { 2120 {
2044 // fall back to our stupid functionality 2121 // fall back to our stupid functionality
2045 pos = RayEnd; 2122 pos = RayEnd;
2046 } 2123 }
2047
2048 return pos;
2049 } 2124 }
2050 } 2125 }
2051 else 2126 else
@@ -2056,8 +2131,12 @@ namespace OpenSim.Region.Framework.Scenes
2056 //increase height so its above the ground. 2131 //increase height so its above the ground.
2057 //should be getting the normal of the ground at the rez point and using that? 2132 //should be getting the normal of the ground at the rez point and using that?
2058 pos.Z += scale.Z / 2f; 2133 pos.Z += scale.Z / 2f;
2059 return pos; 2134// return pos;
2060 } 2135 }
2136
2137 // check against posible water intercept
2138 if (wpos.Z > pos.Z) pos = wpos;
2139 return pos;
2061 } 2140 }
2062 2141
2063 2142
@@ -2146,7 +2225,10 @@ namespace OpenSim.Region.Framework.Scenes
2146 public bool AddRestoredSceneObject( 2225 public bool AddRestoredSceneObject(
2147 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2226 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2148 { 2227 {
2149 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2228 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2229 if (result)
2230 sceneObject.IsDeleted = false;
2231 return result;
2150 } 2232 }
2151 2233
2152 /// <summary> 2234 /// <summary>
@@ -2238,6 +2320,15 @@ namespace OpenSim.Region.Framework.Scenes
2238 /// </summary> 2320 /// </summary>
2239 public void DeleteAllSceneObjects() 2321 public void DeleteAllSceneObjects()
2240 { 2322 {
2323 DeleteAllSceneObjects(false);
2324 }
2325
2326 /// <summary>
2327 /// Delete every object from the scene. This does not include attachments worn by avatars.
2328 /// </summary>
2329 public void DeleteAllSceneObjects(bool exceptNoCopy)
2330 {
2331 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2241 lock (Entities) 2332 lock (Entities)
2242 { 2333 {
2243 EntityBase[] entities = Entities.GetEntities(); 2334 EntityBase[] entities = Entities.GetEntities();
@@ -2246,11 +2337,24 @@ namespace OpenSim.Region.Framework.Scenes
2246 if (e is SceneObjectGroup) 2337 if (e is SceneObjectGroup)
2247 { 2338 {
2248 SceneObjectGroup sog = (SceneObjectGroup)e; 2339 SceneObjectGroup sog = (SceneObjectGroup)e;
2249 if (!sog.IsAttachment) 2340 if (sog != null && !sog.IsAttachment)
2250 DeleteSceneObject((SceneObjectGroup)e, false); 2341 {
2342 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2343 {
2344 DeleteSceneObject((SceneObjectGroup)e, false);
2345 }
2346 else
2347 {
2348 toReturn.Add((SceneObjectGroup)e);
2349 }
2350 }
2251 } 2351 }
2252 } 2352 }
2253 } 2353 }
2354 if (toReturn.Count > 0)
2355 {
2356 returnObjects(toReturn.ToArray(), UUID.Zero);
2357 }
2254 } 2358 }
2255 2359
2256 /// <summary> 2360 /// <summary>
@@ -2285,6 +2389,12 @@ namespace OpenSim.Region.Framework.Scenes
2285 2389
2286 foreach (SceneObjectPart part in partList) 2390 foreach (SceneObjectPart part in partList)
2287 { 2391 {
2392 if (part.KeyframeMotion != null)
2393 {
2394 part.KeyframeMotion.Delete();
2395 part.KeyframeMotion = null;
2396 }
2397
2288 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) 2398 if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
2289 { 2399 {
2290 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? 2400 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
@@ -2302,6 +2412,8 @@ namespace OpenSim.Region.Framework.Scenes
2302 } 2412 }
2303 2413
2304 group.DeleteGroupFromScene(silent); 2414 group.DeleteGroupFromScene(silent);
2415 if (!silent)
2416 SendKillObject(new List<uint>() { group.LocalId });
2305 2417
2306// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2418// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2307 } 2419 }
@@ -2592,7 +2704,7 @@ namespace OpenSim.Region.Framework.Scenes
2592 // If the user is banned, we won't let any of their objects 2704 // If the user is banned, we won't let any of their objects
2593 // enter. Period. 2705 // enter. Period.
2594 // 2706 //
2595 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2707 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2596 { 2708 {
2597 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2709 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2598 return false; 2710 return false;
@@ -2600,6 +2712,8 @@ namespace OpenSim.Region.Framework.Scenes
2600 2712
2601 if (newPosition != Vector3.Zero) 2713 if (newPosition != Vector3.Zero)
2602 newObject.RootPart.GroupPosition = newPosition; 2714 newObject.RootPart.GroupPosition = newPosition;
2715 if (newObject.RootPart.KeyframeMotion != null)
2716 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2603 2717
2604 if (!AddSceneObject(newObject)) 2718 if (!AddSceneObject(newObject))
2605 { 2719 {
@@ -2644,6 +2758,23 @@ namespace OpenSim.Region.Framework.Scenes
2644 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2758 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2645 public bool AddSceneObject(SceneObjectGroup sceneObject) 2759 public bool AddSceneObject(SceneObjectGroup sceneObject)
2646 { 2760 {
2761 if (sceneObject.OwnerID == UUID.Zero)
2762 {
2763 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2764 return false;
2765 }
2766
2767 // If the user is banned, we won't let any of their objects
2768 // enter. Period.
2769 //
2770 int flags = GetUserFlags(sceneObject.OwnerID);
2771 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2772 {
2773 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2774
2775 return false;
2776 }
2777
2647 // Force allocation of new LocalId 2778 // Force allocation of new LocalId
2648 // 2779 //
2649 SceneObjectPart[] parts = sceneObject.Parts; 2780 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2677,16 +2808,27 @@ namespace OpenSim.Region.Framework.Scenes
2677 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2808 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2678 2809
2679 if (AttachmentsModule != null) 2810 if (AttachmentsModule != null)
2680 AttachmentsModule.AttachObject(sp, grp, 0, false, false); 2811 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false);
2681 } 2812 }
2682 else 2813 else
2683 { 2814 {
2815 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2684 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2816 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2685 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2817 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2686 } 2818 }
2819 if (sceneObject.OwnerID == UUID.Zero)
2820 {
2821 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2822 return false;
2823 }
2687 } 2824 }
2688 else 2825 else
2689 { 2826 {
2827 if (sceneObject.OwnerID == UUID.Zero)
2828 {
2829 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2830 return false;
2831 }
2690 AddRestoredSceneObject(sceneObject, true, false); 2832 AddRestoredSceneObject(sceneObject, true, false);
2691 } 2833 }
2692 2834
@@ -2703,6 +2845,24 @@ namespace OpenSim.Region.Framework.Scenes
2703 return 2; // StateSource.PrimCrossing 2845 return 2; // StateSource.PrimCrossing
2704 } 2846 }
2705 2847
2848 public int GetUserFlags(UUID user)
2849 {
2850 //Unfortunately the SP approach means that the value is cached until region is restarted
2851 /*
2852 ScenePresence sp;
2853 if (TryGetScenePresence(user, out sp))
2854 {
2855 return sp.UserFlags;
2856 }
2857 else
2858 {
2859 */
2860 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2861 if (uac == null)
2862 return 0;
2863 return uac.UserFlags;
2864 //}
2865 }
2706 #endregion 2866 #endregion
2707 2867
2708 #region Add/Remove Avatar Methods 2868 #region Add/Remove Avatar Methods
@@ -2716,7 +2876,7 @@ namespace OpenSim.Region.Framework.Scenes
2716 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2876 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2717 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2877 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2718 2878
2719// CheckHeartbeat(); 2879 CheckHeartbeat();
2720 2880
2721 ScenePresence sp = GetScenePresence(client.AgentId); 2881 ScenePresence sp = GetScenePresence(client.AgentId);
2722 2882
@@ -2770,7 +2930,15 @@ namespace OpenSim.Region.Framework.Scenes
2770 2930
2771 EventManager.TriggerOnNewClient(client); 2931 EventManager.TriggerOnNewClient(client);
2772 if (vialogin) 2932 if (vialogin)
2933 {
2773 EventManager.TriggerOnClientLogin(client); 2934 EventManager.TriggerOnClientLogin(client);
2935 // Send initial parcel data
2936/* this is done on TriggerOnNewClient by landmanegement respective event handler
2937 Vector3 pos = sp.AbsolutePosition;
2938 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2939 land.SendLandUpdateToClient(client);
2940*/
2941 }
2774 2942
2775 return sp; 2943 return sp;
2776 } 2944 }
@@ -2859,19 +3027,14 @@ namespace OpenSim.Region.Framework.Scenes
2859 // and the scene presence and the client, if they exist 3027 // and the scene presence and the client, if they exist
2860 try 3028 try
2861 { 3029 {
2862 // We need to wait for the client to make UDP contact first. 3030 ScenePresence sp = GetScenePresence(agentID);
2863 // It's the UDP contact that creates the scene presence 3031
2864 ScenePresence sp = WaitGetScenePresence(agentID);
2865 if (sp != null) 3032 if (sp != null)
2866 { 3033 {
2867 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3034 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2868
2869 sp.ControllingClient.Close(); 3035 sp.ControllingClient.Close();
2870 } 3036 }
2871 else 3037
2872 {
2873 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2874 }
2875 // BANG! SLASH! 3038 // BANG! SLASH!
2876 m_authenticateHandler.RemoveCircuit(agentID); 3039 m_authenticateHandler.RemoveCircuit(agentID);
2877 3040
@@ -2916,6 +3079,8 @@ namespace OpenSim.Region.Framework.Scenes
2916 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3079 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2917 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3080 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2918 3081
3082 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3083
2919 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3084 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2920 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3085 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2921 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3086 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2972,6 +3137,7 @@ namespace OpenSim.Region.Framework.Scenes
2972 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3137 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2973 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3138 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2974 client.OnCopyInventoryItem += CopyInventoryItem; 3139 client.OnCopyInventoryItem += CopyInventoryItem;
3140 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2975 client.OnMoveInventoryItem += MoveInventoryItem; 3141 client.OnMoveInventoryItem += MoveInventoryItem;
2976 client.OnRemoveInventoryItem += RemoveInventoryItem; 3142 client.OnRemoveInventoryItem += RemoveInventoryItem;
2977 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3143 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3043,6 +3209,8 @@ namespace OpenSim.Region.Framework.Scenes
3043 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3209 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3044 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3210 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3045 3211
3212 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3213
3046 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3214 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3047 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3215 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3048 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3216 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3145,7 +3313,7 @@ namespace OpenSim.Region.Framework.Scenes
3145 /// </summary> 3313 /// </summary>
3146 /// <param name="agentId">The avatar's Unique ID</param> 3314 /// <param name="agentId">The avatar's Unique ID</param>
3147 /// <param name="client">The IClientAPI for the client</param> 3315 /// <param name="client">The IClientAPI for the client</param>
3148 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3316 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3149 { 3317 {
3150 if (EntityTransferModule != null) 3318 if (EntityTransferModule != null)
3151 { 3319 {
@@ -3156,6 +3324,7 @@ namespace OpenSim.Region.Framework.Scenes
3156 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3324 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3157 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3325 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3158 } 3326 }
3327 return false;
3159 } 3328 }
3160 3329
3161 /// <summary> 3330 /// <summary>
@@ -3265,6 +3434,16 @@ namespace OpenSim.Region.Framework.Scenes
3265 /// <param name="flags"></param> 3434 /// <param name="flags"></param>
3266 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3435 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3267 { 3436 {
3437 //Add half the avatar's height so that the user doesn't fall through prims
3438 ScenePresence presence;
3439 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3440 {
3441 if (presence.Appearance != null)
3442 {
3443 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3444 }
3445 }
3446
3268 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3447 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3269 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3448 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3270 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3449 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3381,6 +3560,7 @@ namespace OpenSim.Region.Framework.Scenes
3381 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3560 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3382 3561
3383 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3562 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3563 m_log.Debug("[Scene] The avatar has left the building");
3384 } 3564 }
3385 catch (Exception e) 3565 catch (Exception e)
3386 { 3566 {
@@ -3578,17 +3758,20 @@ namespace OpenSim.Region.Framework.Scenes
3578 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3758 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3579 sp.Name, sp.UUID, RegionInfo.RegionName); 3759 sp.Name, sp.UUID, RegionInfo.RegionName);
3580 3760
3581 sp.ControllingClient.Close(true); 3761 sp.ControllingClient.Close(true, true);
3582 sp = null; 3762 sp = null;
3583 } 3763 }
3584 3764
3585 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3586 3765
3587 //On login test land permisions 3766 //On login test land permisions
3588 if (vialogin) 3767 if (vialogin)
3589 { 3768 {
3590 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3769 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3770 if (cache != null)
3771 cache.Remove(agent.firstname + " " + agent.lastname);
3772 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3591 { 3773 {
3774 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3592 return false; 3775 return false;
3593 } 3776 }
3594 } 3777 }
@@ -3611,9 +3794,15 @@ namespace OpenSim.Region.Framework.Scenes
3611 3794
3612 try 3795 try
3613 { 3796 {
3614 if (!AuthorizeUser(agent, out reason)) 3797 // Always check estate if this is a login. Always
3615 return false; 3798 // check if banned regions are to be blacked out.
3616 } catch (Exception e) 3799 if (vialogin || (!m_seeIntoBannedRegion))
3800 {
3801 if (!AuthorizeUser(agent, out reason))
3802 return false;
3803 }
3804 }
3805 catch (Exception e)
3617 { 3806 {
3618 m_log.ErrorFormat( 3807 m_log.ErrorFormat(
3619 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3808 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@@ -3744,6 +3933,8 @@ namespace OpenSim.Region.Framework.Scenes
3744 } 3933 }
3745 3934
3746 // Honor parcel landing type and position. 3935 // Honor parcel landing type and position.
3936 /*
3937 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3747 if (land != null) 3938 if (land != null)
3748 { 3939 {
3749 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3940 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3751,25 +3942,43 @@ namespace OpenSim.Region.Framework.Scenes
3751 agent.startpos = land.LandData.UserLocation; 3942 agent.startpos = land.LandData.UserLocation;
3752 } 3943 }
3753 } 3944 }
3945 */// This is now handled properly in ScenePresence.MakeRootAgent
3754 } 3946 }
3755 3947
3756 return true; 3948 return true;
3757 } 3949 }
3758 3950
3759 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3951 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3760 { 3952 {
3761 bool banned = land.IsBannedFromLand(agent.AgentID); 3953 if (posX < 0)
3762 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3954 posX = 0;
3955 else if (posX >= 256)
3956 posX = 255.999f;
3957 if (posY < 0)
3958 posY = 0;
3959 else if (posY >= 256)
3960 posY = 255.999f;
3961
3962 reason = String.Empty;
3963 if (Permissions.IsGod(agentID))
3964 return true;
3965
3966 ILandObject land = LandChannel.GetLandObject(posX, posY);
3967 if (land == null)
3968 return false;
3969
3970 bool banned = land.IsBannedFromLand(agentID);
3971 bool restricted = land.IsRestrictedFromLand(agentID);
3763 3972
3764 if (banned || restricted) 3973 if (banned || restricted)
3765 { 3974 {
3766 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3975 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3767 if (nearestParcel != null) 3976 if (nearestParcel != null)
3768 { 3977 {
3769 //Move agent to nearest allowed 3978 //Move agent to nearest allowed
3770 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3979 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3771 agent.startpos.X = newPosition.X; 3980 posX = newPosition.X;
3772 agent.startpos.Y = newPosition.Y; 3981 posY = newPosition.Y;
3773 } 3982 }
3774 else 3983 else
3775 { 3984 {
@@ -3831,7 +4040,7 @@ namespace OpenSim.Region.Framework.Scenes
3831 4040
3832 if (!m_strictAccessControl) return true; 4041 if (!m_strictAccessControl) return true;
3833 if (Permissions.IsGod(agent.AgentID)) return true; 4042 if (Permissions.IsGod(agent.AgentID)) return true;
3834 4043
3835 if (AuthorizationService != null) 4044 if (AuthorizationService != null)
3836 { 4045 {
3837 if (!AuthorizationService.IsAuthorizedForRegion( 4046 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3846,7 +4055,7 @@ namespace OpenSim.Region.Framework.Scenes
3846 4055
3847 if (RegionInfo.EstateSettings != null) 4056 if (RegionInfo.EstateSettings != null)
3848 { 4057 {
3849 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4058 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3850 { 4059 {
3851 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4060 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3852 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4061 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4036,6 +4245,15 @@ namespace OpenSim.Region.Framework.Scenes
4036 4245
4037 // XPTO: if this agent is not allowed here as root, always return false 4246 // XPTO: if this agent is not allowed here as root, always return false
4038 4247
4248 // We have to wait until the viewer contacts this region after receiving EAC.
4249 // That calls AddNewClient, which finally creates the ScenePresence
4250 int flags = GetUserFlags(cAgentData.AgentID);
4251 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4252 {
4253 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4254 return false;
4255 }
4256
4039 // TODO: This check should probably be in QueryAccess(). 4257 // TODO: This check should probably be in QueryAccess().
4040 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4258 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4041 if (nearestParcel == null) 4259 if (nearestParcel == null)
@@ -4099,7 +4317,7 @@ namespace OpenSim.Region.Framework.Scenes
4099 /// <param name='agentID'></param> 4317 /// <param name='agentID'></param>
4100 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4318 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4101 { 4319 {
4102 int ntimes = 10; 4320 int ntimes = 30;
4103 ScenePresence sp = null; 4321 ScenePresence sp = null;
4104 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4322 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4105 Thread.Sleep(1000); 4323 Thread.Sleep(1000);
@@ -4129,6 +4347,16 @@ namespace OpenSim.Region.Framework.Scenes
4129 return false; 4347 return false;
4130 } 4348 }
4131 4349
4350 public bool IncomingCloseAgent(UUID agentID)
4351 {
4352 return IncomingCloseAgent(agentID, false);
4353 }
4354
4355 public bool IncomingCloseChildAgent(UUID agentID)
4356 {
4357 return IncomingCloseAgent(agentID, true);
4358 }
4359
4132 /// <summary> 4360 /// <summary>
4133 /// Tell a single agent to disconnect from the region. 4361 /// Tell a single agent to disconnect from the region.
4134 /// </summary> 4362 /// </summary>
@@ -4144,7 +4372,7 @@ namespace OpenSim.Region.Framework.Scenes
4144 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4372 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4145 if (presence != null) 4373 if (presence != null)
4146 { 4374 {
4147 presence.ControllingClient.Close(force); 4375 presence.ControllingClient.Close(true, force);
4148 return true; 4376 return true;
4149 } 4377 }
4150 4378
@@ -4792,35 +5020,81 @@ namespace OpenSim.Region.Framework.Scenes
4792 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 5020 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4793 } 5021 }
4794 5022
4795 public int GetHealth() 5023 public int GetHealth(out int flags, out string message)
4796 { 5024 {
4797 // Returns: 5025 // Returns:
4798 // 1 = sim is up and accepting http requests. The heartbeat has 5026 // 1 = sim is up and accepting http requests. The heartbeat has
4799 // stopped and the sim is probably locked up, but a remote 5027 // stopped and the sim is probably locked up, but a remote
4800 // admin restart may succeed 5028 // admin restart may succeed
4801 // 5029 //
4802 // 2 = Sim is up and the heartbeat is running. The sim is likely 5030 // 2 = Sim is up and the heartbeat is running. The sim is likely
4803 // usable for people within and logins _may_ work 5031 // usable for people within
5032 //
5033 // 3 = Sim is up and one packet thread is running. Sim is
5034 // unstable and will not accept new logins
4804 // 5035 //
4805 // 3 = We have seen a new user enter within the past 4 minutes 5036 // 4 = Sim is up and both packet threads are running. Sim is
5037 // likely usable
5038 //
5039 // 5 = We have seen a new user enter within the past 4 minutes
4806 // which can be seen as positive confirmation of sim health 5040 // which can be seen as positive confirmation of sim health
4807 // 5041 //
5042
5043 flags = 0;
5044 message = String.Empty;
5045
5046 CheckHeartbeat();
5047
5048 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5049 {
5050 // We're still starting
5051 // 0 means "in startup", it can't happen another way, since
5052 // to get here, we must be able to accept http connections
5053 return 0;
5054 }
5055
4808 int health=1; // Start at 1, means we're up 5056 int health=1; // Start at 1, means we're up
4809 5057
4810 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5058 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4811 health += 1; 5059 {
5060 health+=1;
5061 flags |= 1;
5062 }
5063
5064 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5065 {
5066 health+=1;
5067 flags |= 2;
5068 }
5069
5070 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5071 {
5072 health+=1;
5073 flags |= 4;
5074 }
4812 else 5075 else
5076 {
5077int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5078System.Diagnostics.Process proc = new System.Diagnostics.Process();
5079proc.EnableRaisingEvents=false;
5080proc.StartInfo.FileName = "/bin/kill";
5081proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5082proc.Start();
5083proc.WaitForExit();
5084Thread.Sleep(1000);
5085Environment.Exit(1);
5086 }
5087
5088 if (flags != 7)
4813 return health; 5089 return health;
4814 5090
4815 // A login in the last 4 mins? We can't be doing too badly 5091 // A login in the last 4 mins? We can't be doing too badly
4816 // 5092 //
4817 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5093 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4818 health++; 5094 health++;
4819 else 5095 else
4820 return health; 5096 return health;
4821 5097
4822// CheckHeartbeat();
4823
4824 return health; 5098 return health;
4825 } 5099 }
4826 5100
@@ -4908,7 +5182,7 @@ namespace OpenSim.Region.Framework.Scenes
4908 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5182 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4909 if (wasUsingPhysics) 5183 if (wasUsingPhysics)
4910 { 5184 {
4911 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 5185 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
4912 } 5186 }
4913 } 5187 }
4914 5188
@@ -5007,14 +5281,14 @@ namespace OpenSim.Region.Framework.Scenes
5007 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5281 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5008 } 5282 }
5009 5283
5010// private void CheckHeartbeat() 5284 private void CheckHeartbeat()
5011// { 5285 {
5012// if (m_firstHeartbeat) 5286 if (m_firstHeartbeat)
5013// return; 5287 return;
5014// 5288
5015// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5289 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5016// StartTimer(); 5290 Start();
5017// } 5291 }
5018 5292
5019 public override ISceneObject DeserializeObject(string representation) 5293 public override ISceneObject DeserializeObject(string representation)
5020 { 5294 {
@@ -5026,9 +5300,14 @@ namespace OpenSim.Region.Framework.Scenes
5026 get { return m_allowScriptCrossings; } 5300 get { return m_allowScriptCrossings; }
5027 } 5301 }
5028 5302
5029 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5303 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5030 { 5304 {
5031 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5305 return GetNearestAllowedPosition(avatar, null);
5306 }
5307
5308 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5309 {
5310 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
5032 5311
5033 if (nearestParcel != null) 5312 if (nearestParcel != null)
5034 { 5313 {
@@ -5037,10 +5316,7 @@ namespace OpenSim.Region.Framework.Scenes
5037 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5316 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5038 if (nearestPoint != null) 5317 if (nearestPoint != null)
5039 { 5318 {
5040// m_log.DebugFormat( 5319 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
5041// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
5042// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
5043
5044 return nearestPoint.Value; 5320 return nearestPoint.Value;
5045 } 5321 }
5046 5322
@@ -5050,17 +5326,20 @@ namespace OpenSim.Region.Framework.Scenes
5050 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5326 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5051 if (nearestPoint != null) 5327 if (nearestPoint != null)
5052 { 5328 {
5053// m_log.DebugFormat( 5329 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5054// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
5055
5056 return nearestPoint.Value; 5330 return nearestPoint.Value;
5057 } 5331 }
5058 5332
5059 //Ultimate backup if we have no idea where they are 5333 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5060// m_log.DebugFormat( 5334 if (dest != excludeParcel)
5061// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5335 {
5336 // Ultimate backup if we have no idea where they are and
5337 // the last allowed position was in another parcel
5338 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5339 return avatar.lastKnownAllowedPosition;
5340 }
5062 5341
5063 return avatar.lastKnownAllowedPosition; 5342 // else fall through to region edge
5064 } 5343 }
5065 5344
5066 //Go to the edge, this happens in teleporting to a region with no available parcels 5345 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -5094,13 +5373,18 @@ namespace OpenSim.Region.Framework.Scenes
5094 5373
5095 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5374 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5096 { 5375 {
5376 return GetNearestAllowedParcel(avatarId, x, y, null);
5377 }
5378
5379 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5380 {
5097 List<ILandObject> all = AllParcels(); 5381 List<ILandObject> all = AllParcels();
5098 float minParcelDistance = float.MaxValue; 5382 float minParcelDistance = float.MaxValue;
5099 ILandObject nearestParcel = null; 5383 ILandObject nearestParcel = null;
5100 5384
5101 foreach (var parcel in all) 5385 foreach (var parcel in all)
5102 { 5386 {
5103 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5387 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5104 { 5388 {
5105 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5389 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5106 if (parcelDistance < minParcelDistance) 5390 if (parcelDistance < minParcelDistance)
@@ -5342,7 +5626,55 @@ namespace OpenSim.Region.Framework.Scenes
5342 mapModule.GenerateMaptile(); 5626 mapModule.GenerateMaptile();
5343 } 5627 }
5344 5628
5345 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5629// public void CleanDroppedAttachments()
5630// {
5631// List<SceneObjectGroup> objectsToDelete =
5632// new List<SceneObjectGroup>();
5633//
5634// lock (m_cleaningAttachments)
5635// {
5636// ForEachSOG(delegate (SceneObjectGroup grp)
5637// {
5638// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5639// {
5640// UUID agentID = grp.OwnerID;
5641// if (agentID == UUID.Zero)
5642// {
5643// objectsToDelete.Add(grp);
5644// return;
5645// }
5646//
5647// ScenePresence sp = GetScenePresence(agentID);
5648// if (sp == null)
5649// {
5650// objectsToDelete.Add(grp);
5651// return;
5652// }
5653// }
5654// });
5655// }
5656//
5657// foreach (SceneObjectGroup grp in objectsToDelete)
5658// {
5659// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5660// DeleteSceneObject(grp, true);
5661// }
5662// }
5663
5664 public void ThreadAlive(int threadCode)
5665 {
5666 switch(threadCode)
5667 {
5668 case 1: // Incoming
5669 m_lastIncoming = Util.EnvironmentTickCount();
5670 break;
5671 case 2: // Incoming
5672 m_lastOutgoing = Util.EnvironmentTickCount();
5673 break;
5674 }
5675 }
5676
5677 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5346 { 5678 {
5347 RegenerateMaptile(); 5679 RegenerateMaptile();
5348 5680
@@ -5370,6 +5702,8 @@ namespace OpenSim.Region.Framework.Scenes
5370 /// <returns></returns> 5702 /// <returns></returns>
5371 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5703 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5372 { 5704 {
5705 reason = "You are banned from the region";
5706
5373 if (EntityTransferModule.IsInTransit(agentID)) 5707 if (EntityTransferModule.IsInTransit(agentID))
5374 { 5708 {
5375 reason = "Agent is still in transit from this region"; 5709 reason = "Agent is still in transit from this region";
@@ -5381,6 +5715,12 @@ namespace OpenSim.Region.Framework.Scenes
5381 return false; 5715 return false;
5382 } 5716 }
5383 5717
5718 if (Permissions.IsGod(agentID))
5719 {
5720 reason = String.Empty;
5721 return true;
5722 }
5723
5384 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5724 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5385 // However, the long term fix is to make sure root agent count is always accurate. 5725 // However, the long term fix is to make sure root agent count is always accurate.
5386 m_sceneGraph.RecalculateStats(); 5726 m_sceneGraph.RecalculateStats();
@@ -5401,6 +5741,41 @@ namespace OpenSim.Region.Framework.Scenes
5401 } 5741 }
5402 } 5742 }
5403 5743
5744 ScenePresence presence = GetScenePresence(agentID);
5745 IClientAPI client = null;
5746 AgentCircuitData aCircuit = null;
5747
5748 if (presence != null)
5749 {
5750 client = presence.ControllingClient;
5751 if (client != null)
5752 aCircuit = client.RequestClientInfo();
5753 }
5754
5755 // We may be called before there is a presence or a client.
5756 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5757 if (client == null)
5758 {
5759 aCircuit = new AgentCircuitData();
5760 aCircuit.AgentID = agentID;
5761 aCircuit.firstname = String.Empty;
5762 aCircuit.lastname = String.Empty;
5763 }
5764
5765 try
5766 {
5767 if (!AuthorizeUser(aCircuit, out reason))
5768 {
5769 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5770 return false;
5771 }
5772 }
5773 catch (Exception e)
5774 {
5775 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5776 return false;
5777 }
5778
5404 if (position == Vector3.Zero) // Teleport 5779 if (position == Vector3.Zero) // Teleport
5405 { 5780 {
5406 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5781 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5429,13 +5804,46 @@ namespace OpenSim.Region.Framework.Scenes
5429 } 5804 }
5430 } 5805 }
5431 } 5806 }
5807
5808 float posX = 128.0f;
5809 float posY = 128.0f;
5810
5811 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5812 {
5813 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5814 return false;
5815 }
5816 }
5817 else // Walking
5818 {
5819 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5820 if (land == null)
5821 return false;
5822
5823 bool banned = land.IsBannedFromLand(agentID);
5824 bool restricted = land.IsRestrictedFromLand(agentID);
5825
5826 if (banned || restricted)
5827 return false;
5432 } 5828 }
5433 5829
5434 reason = String.Empty; 5830 reason = String.Empty;
5435 return true; 5831 return true;
5436 } 5832 }
5437 5833
5438 /// <summary> 5834 public void StartTimerWatchdog()
5835 {
5836 m_timerWatchdog.Interval = 1000;
5837 m_timerWatchdog.Elapsed += TimerWatchdog;
5838 m_timerWatchdog.AutoReset = true;
5839 m_timerWatchdog.Start();
5840 }
5841
5842 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5843 {
5844 CheckHeartbeat();
5845 }
5846
5439 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5847 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5440 /// autopilot that moves an avatar to a sit target!. 5848 /// autopilot that moves an avatar to a sit target!.
5441 /// </summary> 5849 /// </summary>
@@ -5514,6 +5922,11 @@ namespace OpenSim.Region.Framework.Scenes
5514 return m_SpawnPoint - 1; 5922 return m_SpawnPoint - 1;
5515 } 5923 }
5516 5924
5925 private void HandleGcCollect(string module, string[] args)
5926 {
5927 GC.Collect();
5928 }
5929
5517 // Wrappers to get physics modules retrieve assets. Has to be done this way 5930 // Wrappers to get physics modules retrieve assets. Has to be done this way
5518 // because we can't assign the asset service to physics directly - at the 5931 // because we can't assign the asset service to physics directly - at the
5519 // time physics are instantiated it's not registered but it will be by 5932 // time physics are instantiated it's not registered but it will be by