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.cs810
1 files changed, 609 insertions, 201 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d2d6aba..d9cd2f0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -146,6 +146,7 @@ namespace OpenSim.Region.Framework.Scenes
146 // TODO: need to figure out how allow client agents but deny 146 // TODO: need to figure out how allow client agents but deny
147 // root agents when ACL denies access to root agent 147 // root agents when ACL denies access to root agent
148 public bool m_strictAccessControl = true; 148 public bool m_strictAccessControl = true;
149 public bool m_seeIntoBannedRegion = false;
149 public int MaxUndoCount = 5; 150 public int MaxUndoCount = 5;
150 151
151 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 152 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
@@ -162,12 +163,14 @@ namespace OpenSim.Region.Framework.Scenes
162 163
163 protected int m_splitRegionID; 164 protected int m_splitRegionID;
164 protected Timer m_restartWaitTimer = new Timer(); 165 protected Timer m_restartWaitTimer = new Timer();
166 protected Timer m_timerWatchdog = new Timer();
165 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 167 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
166 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 168 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
167 protected string m_simulatorVersion = "OpenSimulator Server"; 169 protected string m_simulatorVersion = "OpenSimulator Server";
168 protected ModuleLoader m_moduleLoader; 170 protected ModuleLoader m_moduleLoader;
169 protected AgentCircuitManager m_authenticateHandler; 171 protected AgentCircuitManager m_authenticateHandler;
170 protected SceneCommunicationService m_sceneGridService; 172 protected SceneCommunicationService m_sceneGridService;
173 protected ISnmpModule m_snmpService = null;
171 174
172 protected ISimulationDataService m_SimulationDataService; 175 protected ISimulationDataService m_SimulationDataService;
173 protected IEstateDataService m_EstateDataService; 176 protected IEstateDataService m_EstateDataService;
@@ -231,7 +234,7 @@ namespace OpenSim.Region.Framework.Scenes
231 private int m_update_events = 1; 234 private int m_update_events = 1;
232 private int m_update_backup = 200; 235 private int m_update_backup = 200;
233 private int m_update_terrain = 50; 236 private int m_update_terrain = 50;
234// private int m_update_land = 1; 237 private int m_update_land = 10;
235 private int m_update_coarse_locations = 50; 238 private int m_update_coarse_locations = 50;
236 239
237 private int agentMS; 240 private int agentMS;
@@ -244,13 +247,13 @@ namespace OpenSim.Region.Framework.Scenes
244 private int backupMS; 247 private int backupMS;
245 private int terrainMS; 248 private int terrainMS;
246 private int landMS; 249 private int landMS;
247 private int spareMS;
248 250
249 /// <summary> 251 /// <summary>
250 /// Tick at which the last frame was processed. 252 /// Tick at which the last frame was processed.
251 /// </summary> 253 /// </summary>
252 private int m_lastFrameTick; 254 private int m_lastFrameTick;
253 255
256 public bool CombineRegions = false;
254 /// <summary> 257 /// <summary>
255 /// Tick at which the last maintenance run occurred. 258 /// Tick at which the last maintenance run occurred.
256 /// </summary> 259 /// </summary>
@@ -281,6 +284,11 @@ namespace OpenSim.Region.Framework.Scenes
281 /// </summary> 284 /// </summary>
282 private int m_LastLogin; 285 private int m_LastLogin;
283 286
287 private int m_lastIncoming;
288 private int m_lastOutgoing;
289 private int m_hbRestarts = 0;
290
291
284 /// <summary> 292 /// <summary>
285 /// Thread that runs the scene loop. 293 /// Thread that runs the scene loop.
286 /// </summary> 294 /// </summary>
@@ -296,7 +304,7 @@ namespace OpenSim.Region.Framework.Scenes
296 private volatile bool m_shuttingDown; 304 private volatile bool m_shuttingDown;
297 305
298// private int m_lastUpdate; 306// private int m_lastUpdate;
299// private bool m_firstHeartbeat = true; 307 private bool m_firstHeartbeat = true;
300 308
301 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 309 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
302 private bool m_reprioritizationEnabled = true; 310 private bool m_reprioritizationEnabled = true;
@@ -341,6 +349,19 @@ namespace OpenSim.Region.Framework.Scenes
341 get { return m_sceneGridService; } 349 get { return m_sceneGridService; }
342 } 350 }
343 351
352 public ISnmpModule SnmpService
353 {
354 get
355 {
356 if (m_snmpService == null)
357 {
358 m_snmpService = RequestModuleInterface<ISnmpModule>();
359 }
360
361 return m_snmpService;
362 }
363 }
364
344 public ISimulationDataService SimulationDataService 365 public ISimulationDataService SimulationDataService
345 { 366 {
346 get 367 get
@@ -640,6 +661,8 @@ namespace OpenSim.Region.Framework.Scenes
640 m_SimulationDataService = simDataService; 661 m_SimulationDataService = simDataService;
641 m_EstateDataService = estateDataService; 662 m_EstateDataService = estateDataService;
642 m_regionHandle = RegionInfo.RegionHandle; 663 m_regionHandle = RegionInfo.RegionHandle;
664 m_lastIncoming = 0;
665 m_lastOutgoing = 0;
643 666
644 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 667 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
645 m_asyncSceneObjectDeleter.Enabled = true; 668 m_asyncSceneObjectDeleter.Enabled = true;
@@ -722,131 +745,142 @@ namespace OpenSim.Region.Framework.Scenes
722 745
723 // Region config overrides global config 746 // Region config overrides global config
724 // 747 //
725 if (m_config.Configs["Startup"] != null) 748 try
726 { 749 {
727 IConfig startupConfig = m_config.Configs["Startup"]; 750 if (m_config.Configs["Startup"] != null)
728 751 {
729 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 752 IConfig startupConfig = m_config.Configs["Startup"];
730 753
731 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); 754 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
732 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
733 if (!m_useBackup)
734 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
735
736 //Animation states
737 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
738 755
739 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); 756 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
740 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); 757 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
758 if (!m_useBackup)
759 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
760
761 //Animation states
762 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
741 763
742 m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys); 764 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
743 if (RegionInfo.NonphysPrimMin > 0) 765 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
744 {
745 m_minNonphys = RegionInfo.NonphysPrimMin;
746 }
747 766
748 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); 767 m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys);
749 if (RegionInfo.NonphysPrimMax > 0) 768 if (RegionInfo.NonphysPrimMin > 0)
750 { 769 {
751 m_maxNonphys = RegionInfo.NonphysPrimMax; 770 m_minNonphys = RegionInfo.NonphysPrimMin;
752 } 771 }
753 772
754 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); 773 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
755 if (RegionInfo.PhysPrimMin > 0) 774 if (RegionInfo.NonphysPrimMax > 0)
756 { 775 {
757 m_minPhys = RegionInfo.PhysPrimMin; 776 m_maxNonphys = RegionInfo.NonphysPrimMax;
758 } 777 }
759 778
760 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 779 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
761 if (RegionInfo.PhysPrimMax > 0) 780 if (RegionInfo.PhysPrimMin > 0)
762 { 781 {
763 m_maxPhys = RegionInfo.PhysPrimMax; 782 m_minPhys = RegionInfo.PhysPrimMin;
764 } 783 }
765 784
766 // Here, if clamping is requested in either global or 785 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
767 // local config, it will be used
768 //
769 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
770 if (RegionInfo.ClampPrimSize)
771 {
772 m_clampPrimSize = true;
773 }
774 786
775 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 787 if (RegionInfo.PhysPrimMax > 0)
776 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 788 {
777 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 789 m_maxPhys = RegionInfo.PhysPrimMax;
778 m_dontPersistBefore = 790 }
779 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
780 m_dontPersistBefore *= 10000000;
781 m_persistAfter =
782 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
783 m_persistAfter *= 10000000;
784 791
785 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 792 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
793 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
786 794
787 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 795 // Here, if clamping is requested in either global or
788 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 796 // local config, it will be used
797 //
798 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
799 if (RegionInfo.ClampPrimSize)
800 {
801 m_clampPrimSize = true;
802 }
789 803
790 IConfig packetConfig = m_config.Configs["PacketPool"]; 804 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
791 if (packetConfig != null) 805 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
792 { 806 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
793 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); 807 m_dontPersistBefore =
794 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); 808 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
795 } 809 m_dontPersistBefore *= 10000000;
810 m_persistAfter =
811 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
812 m_persistAfter *= 10000000;
813
814 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
815 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
816
817 IConfig packetConfig = m_config.Configs["PacketPool"];
818 if (packetConfig != null)
819 {
820 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
821 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
822 }
796 823
797 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 824 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
825 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
826 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
798 827
799 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 828 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
800 if (m_generateMaptiles) 829 if (m_generateMaptiles)
801 {
802 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
803 if (maptileRefresh != 0)
804 { 830 {
805 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 831 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
806 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; 832 if (maptileRefresh != 0)
807 m_mapGenerationTimer.AutoReset = true; 833 {
808 m_mapGenerationTimer.Start(); 834 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
835 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
836 m_mapGenerationTimer.AutoReset = true;
837 m_mapGenerationTimer.Start();
838 }
809 } 839 }
810 } 840 else
811 else
812 {
813 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
814 UUID tileID;
815
816 if (UUID.TryParse(tile, out tileID))
817 { 841 {
818 RegionInfo.RegionSettings.TerrainImageID = tileID; 842 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
843 UUID tileID;
844
845 if (UUID.TryParse(tile, out tileID))
846 {
847 RegionInfo.RegionSettings.TerrainImageID = tileID;
848 }
819 } 849 }
820 }
821 850
822 string grant = startupConfig.GetString("AllowedClients", String.Empty); 851 string grant = startupConfig.GetString("AllowedClients", String.Empty);
823 if (grant.Length > 0) 852 if (grant.Length > 0)
824 {
825 foreach (string viewer in grant.Split('|'))
826 { 853 {
827 m_AllowedViewers.Add(viewer.Trim().ToLower()); 854 foreach (string viewer in grant.Split(','))
855 {
856 m_AllowedViewers.Add(viewer.Trim().ToLower());
857 }
828 } 858 }
829 }
830 859
831 grant = startupConfig.GetString("BannedClients", String.Empty); 860 grant = startupConfig.GetString("BannedClients", String.Empty);
832 if (grant.Length > 0) 861 if (grant.Length > 0)
833 {
834 foreach (string viewer in grant.Split('|'))
835 { 862 {
836 m_BannedViewers.Add(viewer.Trim().ToLower()); 863 foreach (string viewer in grant.Split(','))
864 {
865 m_BannedViewers.Add(viewer.Trim().ToLower());
866 }
837 } 867 }
838 }
839 868
840 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 869 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
841 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 870 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
842 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 871 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
843 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 872 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
844 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 873 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
845 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); 874 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
846 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); 875 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
847 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); 876 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
848 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 877 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
849 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 878 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
879 }
880 }
881 catch (Exception e)
882 {
883 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
850 } 884 }
851 885
852 // FIXME: Ultimately this should be in a module. 886 // FIXME: Ultimately this should be in a module.
@@ -889,6 +923,8 @@ namespace OpenSim.Region.Framework.Scenes
889 StatsReporter = new SimStatsReporter(this); 923 StatsReporter = new SimStatsReporter(this);
890 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 924 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
891 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 925 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
926
927 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
892 } 928 }
893 929
894 public Scene(RegionInfo regInfo) : base(regInfo) 930 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1291,7 +1327,22 @@ namespace OpenSim.Region.Framework.Scenes
1291 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1327 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1292 if (m_heartbeatThread != null) 1328 if (m_heartbeatThread != null)
1293 { 1329 {
1330 m_hbRestarts++;
1331 if(m_hbRestarts > 10)
1332 Environment.Exit(1);
1333 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1334
1335//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1336//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1337//proc.EnableRaisingEvents=false;
1338//proc.StartInfo.FileName = "/bin/kill";
1339//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1340//proc.Start();
1341//proc.WaitForExit();
1342//Thread.Sleep(1000);
1343//Environment.Exit(1);
1294 m_heartbeatThread.Abort(); 1344 m_heartbeatThread.Abort();
1345 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1295 m_heartbeatThread = null; 1346 m_heartbeatThread = null;
1296 } 1347 }
1297// m_lastUpdate = Util.EnvironmentTickCount(); 1348// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1438,16 +1489,20 @@ namespace OpenSim.Region.Framework.Scenes
1438 endFrame = Frame + frames; 1489 endFrame = Frame + frames;
1439 1490
1440 float physicsFPS = 0f; 1491 float physicsFPS = 0f;
1441 int previousFrameTick, tmpMS; 1492 int tmpMS;
1442 int maintc = Util.EnvironmentTickCount(); 1493 int previousFrameTick;
1494 int maintc;
1495 int sleepMS;
1496 int framestart;
1443 1497
1444 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1498 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1445 { 1499 {
1500 framestart = Util.EnvironmentTickCount();
1446 ++Frame; 1501 ++Frame;
1447 1502
1448// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1503// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1449 1504
1450 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1505 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1451 1506
1452 try 1507 try
1453 { 1508 {
@@ -1499,6 +1554,7 @@ namespace OpenSim.Region.Framework.Scenes
1499 m_sceneGraph.UpdatePresences(); 1554 m_sceneGraph.UpdatePresences();
1500 1555
1501 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1556 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1557
1502 1558
1503 // Delete temp-on-rez stuff 1559 // Delete temp-on-rez stuff
1504 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1560 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1580,34 +1636,37 @@ namespace OpenSim.Region.Framework.Scenes
1580 1636
1581 Watchdog.UpdateThread(); 1637 Watchdog.UpdateThread();
1582 1638
1639 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1640
1641 StatsReporter.AddPhysicsFPS(physicsFPS);
1642 StatsReporter.AddTimeDilation(TimeDilation);
1643 StatsReporter.AddFPS(1);
1644
1645 StatsReporter.addAgentMS(agentMS);
1646 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1647 StatsReporter.addOtherMS(otherMS);
1648 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1649
1583 previousFrameTick = m_lastFrameTick; 1650 previousFrameTick = m_lastFrameTick;
1584 m_lastFrameTick = Util.EnvironmentTickCount(); 1651 m_lastFrameTick = Util.EnvironmentTickCount();
1585 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1652 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1586 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1653 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1587 1654
1655 m_firstHeartbeat = false;
1656
1657 sleepMS = Util.EnvironmentTickCount();
1658
1588 if (tmpMS > 0) 1659 if (tmpMS > 0)
1589 {
1590 Thread.Sleep(tmpMS); 1660 Thread.Sleep(tmpMS);
1591 spareMS += tmpMS;
1592 }
1593
1594 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1595 maintc = Util.EnvironmentTickCount();
1596 1661
1597 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1662 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1663 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1664 StatsReporter.addSleepMS(sleepMS);
1665 StatsReporter.addFrameMS(frameMS);
1598 1666
1599 // if (Frame%m_update_avatars == 0) 1667 // if (Frame%m_update_avatars == 0)
1600 // UpdateInWorldTime(); 1668 // UpdateInWorldTime();
1601 StatsReporter.AddPhysicsFPS(physicsFPS);
1602 StatsReporter.AddTimeDilation(TimeDilation);
1603 StatsReporter.AddFPS(1);
1604 1669
1605 StatsReporter.addFrameMS(frameMS);
1606 StatsReporter.addAgentMS(agentMS);
1607 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1608 StatsReporter.addOtherMS(otherMS);
1609 StatsReporter.AddSpareMS(spareMS);
1610 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1611 1670
1612 // Optionally warn if a frame takes double the amount of time that it should. 1671 // Optionally warn if a frame takes double the amount of time that it should.
1613 if (DebugUpdates 1672 if (DebugUpdates
@@ -1635,9 +1694,9 @@ namespace OpenSim.Region.Framework.Scenes
1635 1694
1636 private void CheckAtTargets() 1695 private void CheckAtTargets()
1637 { 1696 {
1638 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1697 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1639 lock (m_groupsWithTargets) 1698 lock (m_groupsWithTargets)
1640 objs = m_groupsWithTargets.Values; 1699 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1641 1700
1642 foreach (SceneObjectGroup entry in objs) 1701 foreach (SceneObjectGroup entry in objs)
1643 entry.checkAtTargets(); 1702 entry.checkAtTargets();
@@ -1718,7 +1777,7 @@ namespace OpenSim.Region.Framework.Scenes
1718 msg.fromAgentName = "Server"; 1777 msg.fromAgentName = "Server";
1719 msg.dialog = (byte)19; // Object msg 1778 msg.dialog = (byte)19; // Object msg
1720 msg.fromGroup = false; 1779 msg.fromGroup = false;
1721 msg.offline = (byte)0; 1780 msg.offline = (byte)1;
1722 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1781 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1723 msg.Position = Vector3.Zero; 1782 msg.Position = Vector3.Zero;
1724 msg.RegionID = RegionInfo.RegionID.Guid; 1783 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1940,6 +1999,19 @@ namespace OpenSim.Region.Framework.Scenes
1940 EventManager.TriggerPrimsLoaded(this); 1999 EventManager.TriggerPrimsLoaded(this);
1941 } 2000 }
1942 2001
2002 public bool SuportsRayCastFiltered()
2003 {
2004 if (PhysicsScene == null)
2005 return false;
2006 return PhysicsScene.SuportsRaycastWorldFiltered();
2007 }
2008
2009 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2010 {
2011 if (PhysicsScene == null)
2012 return null;
2013 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
2014 }
1943 2015
1944 /// <summary> 2016 /// <summary>
1945 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 2017 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1956,14 +2028,24 @@ namespace OpenSim.Region.Framework.Scenes
1956 /// <returns></returns> 2028 /// <returns></returns>
1957 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 2029 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1958 { 2030 {
2031
2032 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
2033 Vector3 wpos = Vector3.Zero;
2034 // Check for water surface intersection from above
2035 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
2036 {
2037 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
2038 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
2039 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
2040 wpos.Z = wheight;
2041 }
2042
1959 Vector3 pos = Vector3.Zero; 2043 Vector3 pos = Vector3.Zero;
1960 if (RayEndIsIntersection == (byte)1) 2044 if (RayEndIsIntersection == (byte)1)
1961 { 2045 {
1962 pos = RayEnd; 2046 pos = RayEnd;
1963 return pos;
1964 } 2047 }
1965 2048 else if (RayTargetID != UUID.Zero)
1966 if (RayTargetID != UUID.Zero)
1967 { 2049 {
1968 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 2050 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1969 2051
@@ -1985,7 +2067,7 @@ namespace OpenSim.Region.Framework.Scenes
1985 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2067 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1986 2068
1987 // Un-comment out the following line to Get Raytrace results printed to the console. 2069 // Un-comment out the following line to Get Raytrace results printed to the console.
1988 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2070 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1989 float ScaleOffset = 0.5f; 2071 float ScaleOffset = 0.5f;
1990 2072
1991 // If we hit something 2073 // If we hit something
@@ -2008,13 +2090,10 @@ namespace OpenSim.Region.Framework.Scenes
2008 //pos.Z -= 0.25F; 2090 //pos.Z -= 0.25F;
2009 2091
2010 } 2092 }
2011
2012 return pos;
2013 } 2093 }
2014 else 2094 else
2015 { 2095 {
2016 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2096 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2017
2018 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2097 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2019 2098
2020 // Un-comment the following line to print the raytrace results to the console. 2099 // Un-comment the following line to print the raytrace results to the console.
@@ -2023,13 +2102,12 @@ namespace OpenSim.Region.Framework.Scenes
2023 if (ei.HitTF) 2102 if (ei.HitTF)
2024 { 2103 {
2025 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2104 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2026 } else 2105 }
2106 else
2027 { 2107 {
2028 // fall back to our stupid functionality 2108 // fall back to our stupid functionality
2029 pos = RayEnd; 2109 pos = RayEnd;
2030 } 2110 }
2031
2032 return pos;
2033 } 2111 }
2034 } 2112 }
2035 else 2113 else
@@ -2040,8 +2118,12 @@ namespace OpenSim.Region.Framework.Scenes
2040 //increase height so its above the ground. 2118 //increase height so its above the ground.
2041 //should be getting the normal of the ground at the rez point and using that? 2119 //should be getting the normal of the ground at the rez point and using that?
2042 pos.Z += scale.Z / 2f; 2120 pos.Z += scale.Z / 2f;
2043 return pos; 2121// return pos;
2044 } 2122 }
2123
2124 // check against posible water intercept
2125 if (wpos.Z > pos.Z) pos = wpos;
2126 return pos;
2045 } 2127 }
2046 2128
2047 2129
@@ -2130,7 +2212,10 @@ namespace OpenSim.Region.Framework.Scenes
2130 public bool AddRestoredSceneObject( 2212 public bool AddRestoredSceneObject(
2131 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2213 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2132 { 2214 {
2133 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2215 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2216 if (result)
2217 sceneObject.IsDeleted = false;
2218 return result;
2134 } 2219 }
2135 2220
2136 /// <summary> 2221 /// <summary>
@@ -2222,6 +2307,15 @@ namespace OpenSim.Region.Framework.Scenes
2222 /// </summary> 2307 /// </summary>
2223 public void DeleteAllSceneObjects() 2308 public void DeleteAllSceneObjects()
2224 { 2309 {
2310 DeleteAllSceneObjects(false);
2311 }
2312
2313 /// <summary>
2314 /// Delete every object from the scene. This does not include attachments worn by avatars.
2315 /// </summary>
2316 public void DeleteAllSceneObjects(bool exceptNoCopy)
2317 {
2318 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2225 lock (Entities) 2319 lock (Entities)
2226 { 2320 {
2227 EntityBase[] entities = Entities.GetEntities(); 2321 EntityBase[] entities = Entities.GetEntities();
@@ -2230,11 +2324,24 @@ namespace OpenSim.Region.Framework.Scenes
2230 if (e is SceneObjectGroup) 2324 if (e is SceneObjectGroup)
2231 { 2325 {
2232 SceneObjectGroup sog = (SceneObjectGroup)e; 2326 SceneObjectGroup sog = (SceneObjectGroup)e;
2233 if (!sog.IsAttachment) 2327 if (sog != null && !sog.IsAttachment)
2234 DeleteSceneObject((SceneObjectGroup)e, false); 2328 {
2329 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2330 {
2331 DeleteSceneObject((SceneObjectGroup)e, false);
2332 }
2333 else
2334 {
2335 toReturn.Add((SceneObjectGroup)e);
2336 }
2337 }
2235 } 2338 }
2236 } 2339 }
2237 } 2340 }
2341 if (toReturn.Count > 0)
2342 {
2343 returnObjects(toReturn.ToArray(), UUID.Zero);
2344 }
2238 } 2345 }
2239 2346
2240 /// <summary> 2347 /// <summary>
@@ -2286,6 +2393,8 @@ namespace OpenSim.Region.Framework.Scenes
2286 } 2393 }
2287 2394
2288 group.DeleteGroupFromScene(silent); 2395 group.DeleteGroupFromScene(silent);
2396 if (!silent)
2397 SendKillObject(new List<uint>() { group.LocalId });
2289 2398
2290// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2399// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2291 } 2400 }
@@ -2576,7 +2685,7 @@ namespace OpenSim.Region.Framework.Scenes
2576 // If the user is banned, we won't let any of their objects 2685 // If the user is banned, we won't let any of their objects
2577 // enter. Period. 2686 // enter. Period.
2578 // 2687 //
2579 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2688 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2580 { 2689 {
2581 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2690 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2582 return false; 2691 return false;
@@ -2584,6 +2693,8 @@ namespace OpenSim.Region.Framework.Scenes
2584 2693
2585 if (newPosition != Vector3.Zero) 2694 if (newPosition != Vector3.Zero)
2586 newObject.RootPart.GroupPosition = newPosition; 2695 newObject.RootPart.GroupPosition = newPosition;
2696 if (newObject.RootPart.KeyframeMotion != null)
2697 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2587 2698
2588 if (!AddSceneObject(newObject)) 2699 if (!AddSceneObject(newObject))
2589 { 2700 {
@@ -2628,6 +2739,23 @@ namespace OpenSim.Region.Framework.Scenes
2628 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2739 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2629 public bool AddSceneObject(SceneObjectGroup sceneObject) 2740 public bool AddSceneObject(SceneObjectGroup sceneObject)
2630 { 2741 {
2742 if (sceneObject.OwnerID == UUID.Zero)
2743 {
2744 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2745 return false;
2746 }
2747
2748 // If the user is banned, we won't let any of their objects
2749 // enter. Period.
2750 //
2751 int flags = GetUserFlags(sceneObject.OwnerID);
2752 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2753 {
2754 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2755
2756 return false;
2757 }
2758
2631 // Force allocation of new LocalId 2759 // Force allocation of new LocalId
2632 // 2760 //
2633 SceneObjectPart[] parts = sceneObject.Parts; 2761 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2661,16 +2789,27 @@ namespace OpenSim.Region.Framework.Scenes
2661 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2789 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2662 2790
2663 if (AttachmentsModule != null) 2791 if (AttachmentsModule != null)
2664 AttachmentsModule.AttachObject(sp, grp, 0, false, false); 2792 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false);
2665 } 2793 }
2666 else 2794 else
2667 { 2795 {
2796 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2668 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2797 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2669 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2798 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2670 } 2799 }
2800 if (sceneObject.OwnerID == UUID.Zero)
2801 {
2802 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2803 return false;
2804 }
2671 } 2805 }
2672 else 2806 else
2673 { 2807 {
2808 if (sceneObject.OwnerID == UUID.Zero)
2809 {
2810 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2811 return false;
2812 }
2674 AddRestoredSceneObject(sceneObject, true, false); 2813 AddRestoredSceneObject(sceneObject, true, false);
2675 } 2814 }
2676 2815
@@ -2687,6 +2826,24 @@ namespace OpenSim.Region.Framework.Scenes
2687 return 2; // StateSource.PrimCrossing 2826 return 2; // StateSource.PrimCrossing
2688 } 2827 }
2689 2828
2829 public int GetUserFlags(UUID user)
2830 {
2831 //Unfortunately the SP approach means that the value is cached until region is restarted
2832 /*
2833 ScenePresence sp;
2834 if (TryGetScenePresence(user, out sp))
2835 {
2836 return sp.UserFlags;
2837 }
2838 else
2839 {
2840 */
2841 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2842 if (uac == null)
2843 return 0;
2844 return uac.UserFlags;
2845 //}
2846 }
2690 #endregion 2847 #endregion
2691 2848
2692 #region Add/Remove Avatar Methods 2849 #region Add/Remove Avatar Methods
@@ -2700,7 +2857,7 @@ namespace OpenSim.Region.Framework.Scenes
2700 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2857 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2701 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2858 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2702 2859
2703// CheckHeartbeat(); 2860 CheckHeartbeat();
2704 2861
2705 ScenePresence sp = GetScenePresence(client.AgentId); 2862 ScenePresence sp = GetScenePresence(client.AgentId);
2706 2863
@@ -2754,7 +2911,13 @@ namespace OpenSim.Region.Framework.Scenes
2754 2911
2755 EventManager.TriggerOnNewClient(client); 2912 EventManager.TriggerOnNewClient(client);
2756 if (vialogin) 2913 if (vialogin)
2914 {
2757 EventManager.TriggerOnClientLogin(client); 2915 EventManager.TriggerOnClientLogin(client);
2916 // Send initial parcel data
2917 Vector3 pos = sp.AbsolutePosition;
2918 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2919 land.SendLandUpdateToClient(client);
2920 }
2758 2921
2759 return sp; 2922 return sp;
2760 } 2923 }
@@ -2843,19 +3006,14 @@ namespace OpenSim.Region.Framework.Scenes
2843 // and the scene presence and the client, if they exist 3006 // and the scene presence and the client, if they exist
2844 try 3007 try
2845 { 3008 {
2846 // We need to wait for the client to make UDP contact first. 3009 ScenePresence sp = GetScenePresence(agentID);
2847 // It's the UDP contact that creates the scene presence 3010
2848 ScenePresence sp = WaitGetScenePresence(agentID);
2849 if (sp != null) 3011 if (sp != null)
2850 { 3012 {
2851 PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 3013 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2852
2853 sp.ControllingClient.Close(); 3014 sp.ControllingClient.Close();
2854 } 3015 }
2855 else 3016
2856 {
2857 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2858 }
2859 // BANG! SLASH! 3017 // BANG! SLASH!
2860 m_authenticateHandler.RemoveCircuit(agentID); 3018 m_authenticateHandler.RemoveCircuit(agentID);
2861 3019
@@ -2900,6 +3058,8 @@ namespace OpenSim.Region.Framework.Scenes
2900 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3058 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2901 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3059 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2902 3060
3061 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3062
2903 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3063 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2904 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3064 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2905 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3065 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2956,6 +3116,7 @@ namespace OpenSim.Region.Framework.Scenes
2956 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3116 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2957 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3117 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2958 client.OnCopyInventoryItem += CopyInventoryItem; 3118 client.OnCopyInventoryItem += CopyInventoryItem;
3119 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2959 client.OnMoveInventoryItem += MoveInventoryItem; 3120 client.OnMoveInventoryItem += MoveInventoryItem;
2960 client.OnRemoveInventoryItem += RemoveInventoryItem; 3121 client.OnRemoveInventoryItem += RemoveInventoryItem;
2961 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3122 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -3027,6 +3188,8 @@ namespace OpenSim.Region.Framework.Scenes
3027 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3188 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3028 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3189 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3029 3190
3191 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3192
3030 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3193 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3031 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3194 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
3032 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3195 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3129,7 +3292,7 @@ namespace OpenSim.Region.Framework.Scenes
3129 /// </summary> 3292 /// </summary>
3130 /// <param name="agentId">The avatar's Unique ID</param> 3293 /// <param name="agentId">The avatar's Unique ID</param>
3131 /// <param name="client">The IClientAPI for the client</param> 3294 /// <param name="client">The IClientAPI for the client</param>
3132 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3295 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3133 { 3296 {
3134 if (EntityTransferModule != null) 3297 if (EntityTransferModule != null)
3135 { 3298 {
@@ -3140,6 +3303,7 @@ namespace OpenSim.Region.Framework.Scenes
3140 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3303 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3141 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3304 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3142 } 3305 }
3306 return false;
3143 } 3307 }
3144 3308
3145 /// <summary> 3309 /// <summary>
@@ -3249,6 +3413,16 @@ namespace OpenSim.Region.Framework.Scenes
3249 /// <param name="flags"></param> 3413 /// <param name="flags"></param>
3250 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3414 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3251 { 3415 {
3416 //Add half the avatar's height so that the user doesn't fall through prims
3417 ScenePresence presence;
3418 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3419 {
3420 if (presence.Appearance != null)
3421 {
3422 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3423 }
3424 }
3425
3252 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3426 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3253 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3427 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3254 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3428 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3365,6 +3539,7 @@ namespace OpenSim.Region.Framework.Scenes
3365 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3539 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3366 3540
3367 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3541 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3542 m_log.Debug("[Scene] The avatar has left the building");
3368 } 3543 }
3369 catch (Exception e) 3544 catch (Exception e)
3370 { 3545 {
@@ -3566,13 +3741,16 @@ namespace OpenSim.Region.Framework.Scenes
3566 sp = null; 3741 sp = null;
3567 } 3742 }
3568 3743
3569 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3570 3744
3571 //On login test land permisions 3745 //On login test land permisions
3572 if (vialogin) 3746 if (vialogin)
3573 { 3747 {
3574 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3748 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3749 if (cache != null)
3750 cache.Remove(agent.firstname + " " + agent.lastname);
3751 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3575 { 3752 {
3753 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3576 return false; 3754 return false;
3577 } 3755 }
3578 } 3756 }
@@ -3595,9 +3773,15 @@ namespace OpenSim.Region.Framework.Scenes
3595 3773
3596 try 3774 try
3597 { 3775 {
3598 if (!AuthorizeUser(agent, out reason)) 3776 // Always check estate if this is a login. Always
3599 return false; 3777 // check if banned regions are to be blacked out.
3600 } catch (Exception e) 3778 if (vialogin || (!m_seeIntoBannedRegion))
3779 {
3780 if (!AuthorizeUser(agent, out reason))
3781 return false;
3782 }
3783 }
3784 catch (Exception e)
3601 { 3785 {
3602 m_log.ErrorFormat( 3786 m_log.ErrorFormat(
3603 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3787 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@@ -3728,6 +3912,8 @@ namespace OpenSim.Region.Framework.Scenes
3728 } 3912 }
3729 3913
3730 // Honor parcel landing type and position. 3914 // Honor parcel landing type and position.
3915 /*
3916 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3731 if (land != null) 3917 if (land != null)
3732 { 3918 {
3733 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3919 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3735,25 +3921,43 @@ namespace OpenSim.Region.Framework.Scenes
3735 agent.startpos = land.LandData.UserLocation; 3921 agent.startpos = land.LandData.UserLocation;
3736 } 3922 }
3737 } 3923 }
3924 */// This is now handled properly in ScenePresence.MakeRootAgent
3738 } 3925 }
3739 3926
3740 return true; 3927 return true;
3741 } 3928 }
3742 3929
3743 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3930 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3744 { 3931 {
3745 bool banned = land.IsBannedFromLand(agent.AgentID); 3932 if (posX < 0)
3746 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3933 posX = 0;
3934 else if (posX >= 256)
3935 posX = 255.999f;
3936 if (posY < 0)
3937 posY = 0;
3938 else if (posY >= 256)
3939 posY = 255.999f;
3940
3941 reason = String.Empty;
3942 if (Permissions.IsGod(agentID))
3943 return true;
3944
3945 ILandObject land = LandChannel.GetLandObject(posX, posY);
3946 if (land == null)
3947 return false;
3948
3949 bool banned = land.IsBannedFromLand(agentID);
3950 bool restricted = land.IsRestrictedFromLand(agentID);
3747 3951
3748 if (banned || restricted) 3952 if (banned || restricted)
3749 { 3953 {
3750 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3954 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3751 if (nearestParcel != null) 3955 if (nearestParcel != null)
3752 { 3956 {
3753 //Move agent to nearest allowed 3957 //Move agent to nearest allowed
3754 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3958 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3755 agent.startpos.X = newPosition.X; 3959 posX = newPosition.X;
3756 agent.startpos.Y = newPosition.Y; 3960 posY = newPosition.Y;
3757 } 3961 }
3758 else 3962 else
3759 { 3963 {
@@ -3815,7 +4019,7 @@ namespace OpenSim.Region.Framework.Scenes
3815 4019
3816 if (!m_strictAccessControl) return true; 4020 if (!m_strictAccessControl) return true;
3817 if (Permissions.IsGod(agent.AgentID)) return true; 4021 if (Permissions.IsGod(agent.AgentID)) return true;
3818 4022
3819 if (AuthorizationService != null) 4023 if (AuthorizationService != null)
3820 { 4024 {
3821 if (!AuthorizationService.IsAuthorizedForRegion( 4025 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3830,7 +4034,7 @@ namespace OpenSim.Region.Framework.Scenes
3830 4034
3831 if (RegionInfo.EstateSettings != null) 4035 if (RegionInfo.EstateSettings != null)
3832 { 4036 {
3833 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4037 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3834 { 4038 {
3835 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4039 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3836 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4040 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -4020,6 +4224,15 @@ namespace OpenSim.Region.Framework.Scenes
4020 4224
4021 // XPTO: if this agent is not allowed here as root, always return false 4225 // XPTO: if this agent is not allowed here as root, always return false
4022 4226
4227 // We have to wait until the viewer contacts this region after receiving EAC.
4228 // That calls AddNewClient, which finally creates the ScenePresence
4229 int flags = GetUserFlags(cAgentData.AgentID);
4230 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4231 {
4232 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4233 return false;
4234 }
4235
4023 // TODO: This check should probably be in QueryAccess(). 4236 // TODO: This check should probably be in QueryAccess().
4024 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4237 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4025 if (nearestParcel == null) 4238 if (nearestParcel == null)
@@ -4083,7 +4296,7 @@ namespace OpenSim.Region.Framework.Scenes
4083 /// <param name='agentID'></param> 4296 /// <param name='agentID'></param>
4084 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4297 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4085 { 4298 {
4086 int ntimes = 10; 4299 int ntimes = 20;
4087 ScenePresence sp = null; 4300 ScenePresence sp = null;
4088 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4301 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4089 Thread.Sleep(1000); 4302 Thread.Sleep(1000);
@@ -4113,12 +4326,22 @@ namespace OpenSim.Region.Framework.Scenes
4113 return false; 4326 return false;
4114 } 4327 }
4115 4328
4329 public bool IncomingCloseAgent(UUID agentID)
4330 {
4331 return IncomingCloseAgent(agentID, false);
4332 }
4333
4334 public bool IncomingCloseChildAgent(UUID agentID)
4335 {
4336 return IncomingCloseAgent(agentID, true);
4337 }
4338
4116 /// <summary> 4339 /// <summary>
4117 /// Tell a single agent to disconnect from the region. 4340 /// Tell a single agent to disconnect from the region.
4118 /// </summary> 4341 /// </summary>
4119 /// <param name="regionHandle"></param>
4120 /// <param name="agentID"></param> 4342 /// <param name="agentID"></param>
4121 public bool IncomingCloseAgent(UUID agentID) 4343 /// <param name="childOnly"></param>
4344 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
4122 { 4345 {
4123 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4346 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4124 4347
@@ -4739,35 +4962,81 @@ namespace OpenSim.Region.Framework.Scenes
4739 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 4962 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4740 } 4963 }
4741 4964
4742 public int GetHealth() 4965 public int GetHealth(out int flags, out string message)
4743 { 4966 {
4744 // Returns: 4967 // Returns:
4745 // 1 = sim is up and accepting http requests. The heartbeat has 4968 // 1 = sim is up and accepting http requests. The heartbeat has
4746 // stopped and the sim is probably locked up, but a remote 4969 // stopped and the sim is probably locked up, but a remote
4747 // admin restart may succeed 4970 // admin restart may succeed
4748 // 4971 //
4749 // 2 = Sim is up and the heartbeat is running. The sim is likely 4972 // 2 = Sim is up and the heartbeat is running. The sim is likely
4750 // usable for people within and logins _may_ work 4973 // usable for people within
4751 // 4974 //
4752 // 3 = We have seen a new user enter within the past 4 minutes 4975 // 3 = Sim is up and one packet thread is running. Sim is
4976 // unstable and will not accept new logins
4977 //
4978 // 4 = Sim is up and both packet threads are running. Sim is
4979 // likely usable
4980 //
4981 // 5 = We have seen a new user enter within the past 4 minutes
4753 // which can be seen as positive confirmation of sim health 4982 // which can be seen as positive confirmation of sim health
4754 // 4983 //
4984
4985 flags = 0;
4986 message = String.Empty;
4987
4988 CheckHeartbeat();
4989
4990 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4991 {
4992 // We're still starting
4993 // 0 means "in startup", it can't happen another way, since
4994 // to get here, we must be able to accept http connections
4995 return 0;
4996 }
4997
4755 int health=1; // Start at 1, means we're up 4998 int health=1; // Start at 1, means we're up
4756 4999
4757 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5000 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4758 health += 1; 5001 {
5002 health+=1;
5003 flags |= 1;
5004 }
5005
5006 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5007 {
5008 health+=1;
5009 flags |= 2;
5010 }
5011
5012 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5013 {
5014 health+=1;
5015 flags |= 4;
5016 }
4759 else 5017 else
5018 {
5019int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5020System.Diagnostics.Process proc = new System.Diagnostics.Process();
5021proc.EnableRaisingEvents=false;
5022proc.StartInfo.FileName = "/bin/kill";
5023proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
5024proc.Start();
5025proc.WaitForExit();
5026Thread.Sleep(1000);
5027Environment.Exit(1);
5028 }
5029
5030 if (flags != 7)
4760 return health; 5031 return health;
4761 5032
4762 // A login in the last 4 mins? We can't be doing too badly 5033 // A login in the last 4 mins? We can't be doing too badly
4763 // 5034 //
4764 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5035 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4765 health++; 5036 health++;
4766 else 5037 else
4767 return health; 5038 return health;
4768 5039
4769// CheckHeartbeat();
4770
4771 return health; 5040 return health;
4772 } 5041 }
4773 5042
@@ -4855,7 +5124,7 @@ namespace OpenSim.Region.Framework.Scenes
4855 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5124 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4856 if (wasUsingPhysics) 5125 if (wasUsingPhysics)
4857 { 5126 {
4858 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 5127 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
4859 } 5128 }
4860 } 5129 }
4861 5130
@@ -4954,14 +5223,14 @@ namespace OpenSim.Region.Framework.Scenes
4954 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5223 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
4955 } 5224 }
4956 5225
4957// private void CheckHeartbeat() 5226 private void CheckHeartbeat()
4958// { 5227 {
4959// if (m_firstHeartbeat) 5228 if (m_firstHeartbeat)
4960// return; 5229 return;
4961// 5230
4962// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5231 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
4963// StartTimer(); 5232 Start();
4964// } 5233 }
4965 5234
4966 public override ISceneObject DeserializeObject(string representation) 5235 public override ISceneObject DeserializeObject(string representation)
4967 { 5236 {
@@ -4973,9 +5242,14 @@ namespace OpenSim.Region.Framework.Scenes
4973 get { return m_allowScriptCrossings; } 5242 get { return m_allowScriptCrossings; }
4974 } 5243 }
4975 5244
4976 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5245 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5246 {
5247 return GetNearestAllowedPosition(avatar, null);
5248 }
5249
5250 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
4977 { 5251 {
4978 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5252 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4979 5253
4980 if (nearestParcel != null) 5254 if (nearestParcel != null)
4981 { 5255 {
@@ -4984,10 +5258,7 @@ namespace OpenSim.Region.Framework.Scenes
4984 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5258 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4985 if (nearestPoint != null) 5259 if (nearestPoint != null)
4986 { 5260 {
4987// m_log.DebugFormat( 5261 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4988// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
4989// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
4990
4991 return nearestPoint.Value; 5262 return nearestPoint.Value;
4992 } 5263 }
4993 5264
@@ -4997,17 +5268,20 @@ namespace OpenSim.Region.Framework.Scenes
4997 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5268 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4998 if (nearestPoint != null) 5269 if (nearestPoint != null)
4999 { 5270 {
5000// m_log.DebugFormat( 5271 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5001// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
5002
5003 return nearestPoint.Value; 5272 return nearestPoint.Value;
5004 } 5273 }
5005 5274
5006 //Ultimate backup if we have no idea where they are 5275 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5007// m_log.DebugFormat( 5276 if (dest != excludeParcel)
5008// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5277 {
5278 // Ultimate backup if we have no idea where they are and
5279 // the last allowed position was in another parcel
5280 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5281 return avatar.lastKnownAllowedPosition;
5282 }
5009 5283
5010 return avatar.lastKnownAllowedPosition; 5284 // else fall through to region edge
5011 } 5285 }
5012 5286
5013 //Go to the edge, this happens in teleporting to a region with no available parcels 5287 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -5041,13 +5315,18 @@ namespace OpenSim.Region.Framework.Scenes
5041 5315
5042 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5316 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5043 { 5317 {
5318 return GetNearestAllowedParcel(avatarId, x, y, null);
5319 }
5320
5321 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5322 {
5044 List<ILandObject> all = AllParcels(); 5323 List<ILandObject> all = AllParcels();
5045 float minParcelDistance = float.MaxValue; 5324 float minParcelDistance = float.MaxValue;
5046 ILandObject nearestParcel = null; 5325 ILandObject nearestParcel = null;
5047 5326
5048 foreach (var parcel in all) 5327 foreach (var parcel in all)
5049 { 5328 {
5050 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5329 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5051 { 5330 {
5052 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5331 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5053 if (parcelDistance < minParcelDistance) 5332 if (parcelDistance < minParcelDistance)
@@ -5289,7 +5568,55 @@ namespace OpenSim.Region.Framework.Scenes
5289 mapModule.GenerateMaptile(); 5568 mapModule.GenerateMaptile();
5290 } 5569 }
5291 5570
5292 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5571// public void CleanDroppedAttachments()
5572// {
5573// List<SceneObjectGroup> objectsToDelete =
5574// new List<SceneObjectGroup>();
5575//
5576// lock (m_cleaningAttachments)
5577// {
5578// ForEachSOG(delegate (SceneObjectGroup grp)
5579// {
5580// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5581// {
5582// UUID agentID = grp.OwnerID;
5583// if (agentID == UUID.Zero)
5584// {
5585// objectsToDelete.Add(grp);
5586// return;
5587// }
5588//
5589// ScenePresence sp = GetScenePresence(agentID);
5590// if (sp == null)
5591// {
5592// objectsToDelete.Add(grp);
5593// return;
5594// }
5595// }
5596// });
5597// }
5598//
5599// foreach (SceneObjectGroup grp in objectsToDelete)
5600// {
5601// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5602// DeleteSceneObject(grp, true);
5603// }
5604// }
5605
5606 public void ThreadAlive(int threadCode)
5607 {
5608 switch(threadCode)
5609 {
5610 case 1: // Incoming
5611 m_lastIncoming = Util.EnvironmentTickCount();
5612 break;
5613 case 2: // Incoming
5614 m_lastOutgoing = Util.EnvironmentTickCount();
5615 break;
5616 }
5617 }
5618
5619 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5293 { 5620 {
5294 RegenerateMaptile(); 5621 RegenerateMaptile();
5295 5622
@@ -5317,6 +5644,8 @@ namespace OpenSim.Region.Framework.Scenes
5317 /// <returns></returns> 5644 /// <returns></returns>
5318 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5645 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5319 { 5646 {
5647 reason = "You are banned from the region";
5648
5320 if (EntityTransferModule.IsInTransit(agentID)) 5649 if (EntityTransferModule.IsInTransit(agentID))
5321 { 5650 {
5322 reason = "Agent is still in transit from this region"; 5651 reason = "Agent is still in transit from this region";
@@ -5328,6 +5657,12 @@ namespace OpenSim.Region.Framework.Scenes
5328 return false; 5657 return false;
5329 } 5658 }
5330 5659
5660 if (Permissions.IsGod(agentID))
5661 {
5662 reason = String.Empty;
5663 return true;
5664 }
5665
5331 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5666 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5332 // However, the long term fix is to make sure root agent count is always accurate. 5667 // However, the long term fix is to make sure root agent count is always accurate.
5333 m_sceneGraph.RecalculateStats(); 5668 m_sceneGraph.RecalculateStats();
@@ -5348,6 +5683,41 @@ namespace OpenSim.Region.Framework.Scenes
5348 } 5683 }
5349 } 5684 }
5350 5685
5686 ScenePresence presence = GetScenePresence(agentID);
5687 IClientAPI client = null;
5688 AgentCircuitData aCircuit = null;
5689
5690 if (presence != null)
5691 {
5692 client = presence.ControllingClient;
5693 if (client != null)
5694 aCircuit = client.RequestClientInfo();
5695 }
5696
5697 // We may be called before there is a presence or a client.
5698 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5699 if (client == null)
5700 {
5701 aCircuit = new AgentCircuitData();
5702 aCircuit.AgentID = agentID;
5703 aCircuit.firstname = String.Empty;
5704 aCircuit.lastname = String.Empty;
5705 }
5706
5707 try
5708 {
5709 if (!AuthorizeUser(aCircuit, out reason))
5710 {
5711 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5712 return false;
5713 }
5714 }
5715 catch (Exception e)
5716 {
5717 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5718 return false;
5719 }
5720
5351 if (position == Vector3.Zero) // Teleport 5721 if (position == Vector3.Zero) // Teleport
5352 { 5722 {
5353 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5723 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5376,13 +5746,46 @@ namespace OpenSim.Region.Framework.Scenes
5376 } 5746 }
5377 } 5747 }
5378 } 5748 }
5749
5750 float posX = 128.0f;
5751 float posY = 128.0f;
5752
5753 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5754 {
5755 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5756 return false;
5757 }
5758 }
5759 else // Walking
5760 {
5761 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5762 if (land == null)
5763 return false;
5764
5765 bool banned = land.IsBannedFromLand(agentID);
5766 bool restricted = land.IsRestrictedFromLand(agentID);
5767
5768 if (banned || restricted)
5769 return false;
5379 } 5770 }
5380 5771
5381 reason = String.Empty; 5772 reason = String.Empty;
5382 return true; 5773 return true;
5383 } 5774 }
5384 5775
5385 /// <summary> 5776 public void StartTimerWatchdog()
5777 {
5778 m_timerWatchdog.Interval = 1000;
5779 m_timerWatchdog.Elapsed += TimerWatchdog;
5780 m_timerWatchdog.AutoReset = true;
5781 m_timerWatchdog.Start();
5782 }
5783
5784 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5785 {
5786 CheckHeartbeat();
5787 }
5788
5386 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5789 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5387 /// autopilot that moves an avatar to a sit target!. 5790 /// autopilot that moves an avatar to a sit target!.
5388 /// </summary> 5791 /// </summary>
@@ -5461,6 +5864,11 @@ namespace OpenSim.Region.Framework.Scenes
5461 return m_SpawnPoint - 1; 5864 return m_SpawnPoint - 1;
5462 } 5865 }
5463 5866
5867 private void HandleGcCollect(string module, string[] args)
5868 {
5869 GC.Collect();
5870 }
5871
5464 // Wrappers to get physics modules retrieve assets. Has to be done this way 5872 // Wrappers to get physics modules retrieve assets. Has to be done this way
5465 // because we can't assign the asset service to physics directly - at the 5873 // because we can't assign the asset service to physics directly - at the
5466 // time physics are instantiated it's not registered but it will be by 5874 // time physics are instantiated it's not registered but it will be by