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.cs787
1 files changed, 591 insertions, 196 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ee34338..0bf2259 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -127,6 +127,7 @@ namespace OpenSim.Region.Framework.Scenes
127 // TODO: need to figure out how allow client agents but deny 127 // TODO: need to figure out how allow client agents but deny
128 // root agents when ACL denies access to root agent 128 // root agents when ACL denies access to root agent
129 public bool m_strictAccessControl = true; 129 public bool m_strictAccessControl = true;
130 public bool m_seeIntoBannedRegion = false;
130 public int MaxUndoCount = 5; 131 public int MaxUndoCount = 5;
131 132
132 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 133 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
@@ -143,12 +144,14 @@ namespace OpenSim.Region.Framework.Scenes
143 144
144 protected int m_splitRegionID; 145 protected int m_splitRegionID;
145 protected Timer m_restartWaitTimer = new Timer(); 146 protected Timer m_restartWaitTimer = new Timer();
147 protected Timer m_timerWatchdog = new Timer();
146 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 148 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
147 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 149 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
148 protected string m_simulatorVersion = "OpenSimulator Server"; 150 protected string m_simulatorVersion = "OpenSimulator Server";
149 protected ModuleLoader m_moduleLoader; 151 protected ModuleLoader m_moduleLoader;
150 protected AgentCircuitManager m_authenticateHandler; 152 protected AgentCircuitManager m_authenticateHandler;
151 protected SceneCommunicationService m_sceneGridService; 153 protected SceneCommunicationService m_sceneGridService;
154 protected ISnmpModule m_snmpService = null;
152 155
153 protected ISimulationDataService m_SimulationDataService; 156 protected ISimulationDataService m_SimulationDataService;
154 protected IEstateDataService m_EstateDataService; 157 protected IEstateDataService m_EstateDataService;
@@ -210,7 +213,7 @@ namespace OpenSim.Region.Framework.Scenes
210 private int m_update_events = 1; 213 private int m_update_events = 1;
211 private int m_update_backup = 200; 214 private int m_update_backup = 200;
212 private int m_update_terrain = 50; 215 private int m_update_terrain = 50;
213// private int m_update_land = 1; 216 private int m_update_land = 10;
214 private int m_update_coarse_locations = 50; 217 private int m_update_coarse_locations = 50;
215 218
216 private int agentMS; 219 private int agentMS;
@@ -223,13 +226,13 @@ namespace OpenSim.Region.Framework.Scenes
223 private int backupMS; 226 private int backupMS;
224 private int terrainMS; 227 private int terrainMS;
225 private int landMS; 228 private int landMS;
226 private int spareMS;
227 229
228 /// <summary> 230 /// <summary>
229 /// Tick at which the last frame was processed. 231 /// Tick at which the last frame was processed.
230 /// </summary> 232 /// </summary>
231 private int m_lastFrameTick; 233 private int m_lastFrameTick;
232 234
235 public bool CombineRegions = false;
233 /// <summary> 236 /// <summary>
234 /// Tick at which the last maintenance run occurred. 237 /// Tick at which the last maintenance run occurred.
235 /// </summary> 238 /// </summary>
@@ -260,6 +263,11 @@ namespace OpenSim.Region.Framework.Scenes
260 /// </summary> 263 /// </summary>
261 private int m_LastLogin; 264 private int m_LastLogin;
262 265
266 private int m_lastIncoming;
267 private int m_lastOutgoing;
268 private int m_hbRestarts = 0;
269
270
263 /// <summary> 271 /// <summary>
264 /// Thread that runs the scene loop. 272 /// Thread that runs the scene loop.
265 /// </summary> 273 /// </summary>
@@ -275,7 +283,7 @@ namespace OpenSim.Region.Framework.Scenes
275 private volatile bool m_shuttingDown; 283 private volatile bool m_shuttingDown;
276 284
277// private int m_lastUpdate; 285// private int m_lastUpdate;
278// private bool m_firstHeartbeat = true; 286 private bool m_firstHeartbeat = true;
279 287
280 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 288 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
281 private bool m_reprioritizationEnabled = true; 289 private bool m_reprioritizationEnabled = true;
@@ -320,6 +328,19 @@ namespace OpenSim.Region.Framework.Scenes
320 get { return m_sceneGridService; } 328 get { return m_sceneGridService; }
321 } 329 }
322 330
331 public ISnmpModule SnmpService
332 {
333 get
334 {
335 if (m_snmpService == null)
336 {
337 m_snmpService = RequestModuleInterface<ISnmpModule>();
338 }
339
340 return m_snmpService;
341 }
342 }
343
323 public ISimulationDataService SimulationDataService 344 public ISimulationDataService SimulationDataService
324 { 345 {
325 get 346 get
@@ -619,6 +640,8 @@ namespace OpenSim.Region.Framework.Scenes
619 m_SimulationDataService = simDataService; 640 m_SimulationDataService = simDataService;
620 m_EstateDataService = estateDataService; 641 m_EstateDataService = estateDataService;
621 m_regionHandle = RegionInfo.RegionHandle; 642 m_regionHandle = RegionInfo.RegionHandle;
643 m_lastIncoming = 0;
644 m_lastOutgoing = 0;
622 645
623 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 646 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
624 m_asyncSceneObjectDeleter.Enabled = true; 647 m_asyncSceneObjectDeleter.Enabled = true;
@@ -699,122 +722,131 @@ namespace OpenSim.Region.Framework.Scenes
699 722
700 // Region config overrides global config 723 // Region config overrides global config
701 // 724 //
702 if (m_config.Configs["Startup"] != null) 725 try
703 { 726 {
704 IConfig startupConfig = m_config.Configs["Startup"]; 727 if (m_config.Configs["Startup"] != null)
705
706 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
707
708 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
709 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
710 if (!m_useBackup)
711 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
712
713 //Animation states
714 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
715
716 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
717 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
718
719 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
720 if (RegionInfo.NonphysPrimMax > 0)
721 { 728 {
722 m_maxNonphys = RegionInfo.NonphysPrimMax; 729 IConfig startupConfig = m_config.Configs["Startup"];
723 }
724 730
725 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 731 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
726 732
727 if (RegionInfo.PhysPrimMax > 0) 733 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
728 { 734 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
729 m_maxPhys = RegionInfo.PhysPrimMax; 735 if (!m_useBackup)
730 } 736 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
731 737
732 // Here, if clamping is requested in either global or 738 //Animation states
733 // local config, it will be used 739 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
734 //
735 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
736 if (RegionInfo.ClampPrimSize)
737 {
738 m_clampPrimSize = true;
739 }
740 740
741 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 741 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
742 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 742 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
743 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
744 m_dontPersistBefore =
745 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
746 m_dontPersistBefore *= 10000000;
747 m_persistAfter =
748 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
749 m_persistAfter *= 10000000;
750 743
751 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 744 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
745 if (RegionInfo.NonphysPrimMax > 0)
746 {
747 m_maxNonphys = RegionInfo.NonphysPrimMax;
748 }
752 749
753 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 750 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
754 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
755 751
756 IConfig packetConfig = m_config.Configs["PacketPool"]; 752 if (RegionInfo.PhysPrimMax > 0)
757 if (packetConfig != null) 753 {
758 { 754 m_maxPhys = RegionInfo.PhysPrimMax;
759 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); 755 }
760 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
761 }
762 756
763 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 757 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
758 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
764 759
765 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 760 // Here, if clamping is requested in either global or
766 if (m_generateMaptiles) 761 // local config, it will be used
767 { 762 //
768 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 763 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
769 if (maptileRefresh != 0) 764 if (RegionInfo.ClampPrimSize)
770 { 765 {
771 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 766 m_clampPrimSize = true;
772 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
773 m_mapGenerationTimer.AutoReset = true;
774 m_mapGenerationTimer.Start();
775 } 767 }
776 }
777 else
778 {
779 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
780 UUID tileID;
781 768
782 if (UUID.TryParse(tile, out tileID)) 769 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
770 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
771 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
772 m_dontPersistBefore =
773 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
774 m_dontPersistBefore *= 10000000;
775 m_persistAfter =
776 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
777 m_persistAfter *= 10000000;
778
779 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
780 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
781
782 IConfig packetConfig = m_config.Configs["PacketPool"];
783 if (packetConfig != null)
783 { 784 {
784 RegionInfo.RegionSettings.TerrainImageID = tileID; 785 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
786 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
785 } 787 }
786 }
787 788
788 string grant = startupConfig.GetString("AllowedClients", String.Empty); 789 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
789 if (grant.Length > 0) 790 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
790 { 791 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
791 foreach (string viewer in grant.Split('|')) 792
793 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
794 if (m_generateMaptiles)
792 { 795 {
793 m_AllowedViewers.Add(viewer.Trim().ToLower()); 796 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
797 if (maptileRefresh != 0)
798 {
799 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
800 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
801 m_mapGenerationTimer.AutoReset = true;
802 m_mapGenerationTimer.Start();
803 }
794 } 804 }
795 } 805 else
806 {
807 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
808 UUID tileID;
796 809
797 grant = startupConfig.GetString("BannedClients", String.Empty); 810 if (UUID.TryParse(tile, out tileID))
798 if (grant.Length > 0) 811 {
799 { 812 RegionInfo.RegionSettings.TerrainImageID = tileID;
800 foreach (string viewer in grant.Split('|')) 813 }
814 }
815
816 string grant = startupConfig.GetString("AllowedClients", String.Empty);
817 if (grant.Length > 0)
801 { 818 {
802 m_BannedViewers.Add(viewer.Trim().ToLower()); 819 foreach (string viewer in grant.Split(','))
820 {
821 m_AllowedViewers.Add(viewer.Trim().ToLower());
822 }
803 } 823 }
804 }
805 824
806 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 825 grant = startupConfig.GetString("BannedClients", String.Empty);
807 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 826 if (grant.Length > 0)
808 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 827 {
809 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 828 foreach (string viewer in grant.Split(','))
810 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 829 {
811 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); 830 m_BannedViewers.Add(viewer.Trim().ToLower());
812 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); 831 }
813 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); 832 }
814 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
815 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
816 833
817 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); 834 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
835 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
836 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
837 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
838 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
839 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
840 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
841 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
842 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
843 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
844 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates);
845 }
846 }
847 catch (Exception e)
848 {
849 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
818 } 850 }
819 851
820 #endregion Region Config 852 #endregion Region Config
@@ -849,6 +881,8 @@ namespace OpenSim.Region.Framework.Scenes
849 StatsReporter = new SimStatsReporter(this); 881 StatsReporter = new SimStatsReporter(this);
850 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 882 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
851 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 883 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
884
885 MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect);
852 } 886 }
853 887
854 public Scene(RegionInfo regInfo) : base(regInfo) 888 public Scene(RegionInfo regInfo) : base(regInfo)
@@ -1240,7 +1274,22 @@ namespace OpenSim.Region.Framework.Scenes
1240 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1274 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1241 if (m_heartbeatThread != null) 1275 if (m_heartbeatThread != null)
1242 { 1276 {
1277 m_hbRestarts++;
1278 if(m_hbRestarts > 10)
1279 Environment.Exit(1);
1280 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1281
1282//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1283//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1284//proc.EnableRaisingEvents=false;
1285//proc.StartInfo.FileName = "/bin/kill";
1286//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1287//proc.Start();
1288//proc.WaitForExit();
1289//Thread.Sleep(1000);
1290//Environment.Exit(1);
1243 m_heartbeatThread.Abort(); 1291 m_heartbeatThread.Abort();
1292 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1244 m_heartbeatThread = null; 1293 m_heartbeatThread = null;
1245 } 1294 }
1246// m_lastUpdate = Util.EnvironmentTickCount(); 1295// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1387,16 +1436,20 @@ namespace OpenSim.Region.Framework.Scenes
1387 endFrame = Frame + frames; 1436 endFrame = Frame + frames;
1388 1437
1389 float physicsFPS = 0f; 1438 float physicsFPS = 0f;
1390 int previousFrameTick, tmpMS; 1439 int tmpMS;
1391 int maintc = Util.EnvironmentTickCount(); 1440 int previousFrameTick;
1441 int maintc;
1442 int sleepMS;
1443 int framestart;
1392 1444
1393 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1445 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1394 { 1446 {
1447 framestart = Util.EnvironmentTickCount();
1395 ++Frame; 1448 ++Frame;
1396 1449
1397// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1450// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1398 1451
1399 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1452 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1400 1453
1401 try 1454 try
1402 { 1455 {
@@ -1448,6 +1501,7 @@ namespace OpenSim.Region.Framework.Scenes
1448 m_sceneGraph.UpdatePresences(); 1501 m_sceneGraph.UpdatePresences();
1449 1502
1450 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1503 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1504
1451 1505
1452 // Delete temp-on-rez stuff 1506 // Delete temp-on-rez stuff
1453 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1507 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1529,34 +1583,37 @@ namespace OpenSim.Region.Framework.Scenes
1529 1583
1530 Watchdog.UpdateThread(); 1584 Watchdog.UpdateThread();
1531 1585
1586 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1587
1588 StatsReporter.AddPhysicsFPS(physicsFPS);
1589 StatsReporter.AddTimeDilation(TimeDilation);
1590 StatsReporter.AddFPS(1);
1591
1592 StatsReporter.addAgentMS(agentMS);
1593 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1594 StatsReporter.addOtherMS(otherMS);
1595 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1596
1532 previousFrameTick = m_lastFrameTick; 1597 previousFrameTick = m_lastFrameTick;
1533 m_lastFrameTick = Util.EnvironmentTickCount(); 1598 m_lastFrameTick = Util.EnvironmentTickCount();
1534 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1599 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1535 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1600 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1536 1601
1602 m_firstHeartbeat = false;
1603
1604 sleepMS = Util.EnvironmentTickCount();
1605
1537 if (tmpMS > 0) 1606 if (tmpMS > 0)
1538 {
1539 Thread.Sleep(tmpMS); 1607 Thread.Sleep(tmpMS);
1540 spareMS += tmpMS;
1541 }
1542
1543 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1544 maintc = Util.EnvironmentTickCount();
1545 1608
1546 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1609 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1610 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1611 StatsReporter.addSleepMS(sleepMS);
1612 StatsReporter.addFrameMS(frameMS);
1547 1613
1548 // if (Frame%m_update_avatars == 0) 1614 // if (Frame%m_update_avatars == 0)
1549 // UpdateInWorldTime(); 1615 // UpdateInWorldTime();
1550 StatsReporter.AddPhysicsFPS(physicsFPS);
1551 StatsReporter.AddTimeDilation(TimeDilation);
1552 StatsReporter.AddFPS(1);
1553 1616
1554 StatsReporter.addFrameMS(frameMS);
1555 StatsReporter.addAgentMS(agentMS);
1556 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1557 StatsReporter.addOtherMS(otherMS);
1558 StatsReporter.AddSpareMS(spareMS);
1559 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1560 1617
1561 // Optionally warn if a frame takes double the amount of time that it should. 1618 // Optionally warn if a frame takes double the amount of time that it should.
1562 if (DebugUpdates 1619 if (DebugUpdates
@@ -1584,9 +1641,9 @@ namespace OpenSim.Region.Framework.Scenes
1584 1641
1585 private void CheckAtTargets() 1642 private void CheckAtTargets()
1586 { 1643 {
1587 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1644 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1588 lock (m_groupsWithTargets) 1645 lock (m_groupsWithTargets)
1589 objs = m_groupsWithTargets.Values; 1646 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1590 1647
1591 foreach (SceneObjectGroup entry in objs) 1648 foreach (SceneObjectGroup entry in objs)
1592 entry.checkAtTargets(); 1649 entry.checkAtTargets();
@@ -1667,7 +1724,7 @@ namespace OpenSim.Region.Framework.Scenes
1667 msg.fromAgentName = "Server"; 1724 msg.fromAgentName = "Server";
1668 msg.dialog = (byte)19; // Object msg 1725 msg.dialog = (byte)19; // Object msg
1669 msg.fromGroup = false; 1726 msg.fromGroup = false;
1670 msg.offline = (byte)0; 1727 msg.offline = (byte)1;
1671 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1728 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1672 msg.Position = Vector3.Zero; 1729 msg.Position = Vector3.Zero;
1673 msg.RegionID = RegionInfo.RegionID.Guid; 1730 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1889,6 +1946,19 @@ namespace OpenSim.Region.Framework.Scenes
1889 EventManager.TriggerPrimsLoaded(this); 1946 EventManager.TriggerPrimsLoaded(this);
1890 } 1947 }
1891 1948
1949 public bool SuportsRayCastFiltered()
1950 {
1951 if (PhysicsScene == null)
1952 return false;
1953 return PhysicsScene.SuportsRaycastWorldFiltered();
1954 }
1955
1956 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
1957 {
1958 if (PhysicsScene == null)
1959 return null;
1960 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
1961 }
1892 1962
1893 /// <summary> 1963 /// <summary>
1894 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 1964 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1905,14 +1975,24 @@ namespace OpenSim.Region.Framework.Scenes
1905 /// <returns></returns> 1975 /// <returns></returns>
1906 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1976 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1907 { 1977 {
1978
1979 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1980 Vector3 wpos = Vector3.Zero;
1981 // Check for water surface intersection from above
1982 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1983 {
1984 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1985 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1986 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1987 wpos.Z = wheight;
1988 }
1989
1908 Vector3 pos = Vector3.Zero; 1990 Vector3 pos = Vector3.Zero;
1909 if (RayEndIsIntersection == (byte)1) 1991 if (RayEndIsIntersection == (byte)1)
1910 { 1992 {
1911 pos = RayEnd; 1993 pos = RayEnd;
1912 return pos;
1913 } 1994 }
1914 1995 else if (RayTargetID != UUID.Zero)
1915 if (RayTargetID != UUID.Zero)
1916 { 1996 {
1917 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1997 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1918 1998
@@ -1934,7 +2014,7 @@ namespace OpenSim.Region.Framework.Scenes
1934 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2014 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1935 2015
1936 // Un-comment out the following line to Get Raytrace results printed to the console. 2016 // Un-comment out the following line to Get Raytrace results printed to the console.
1937 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2017 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1938 float ScaleOffset = 0.5f; 2018 float ScaleOffset = 0.5f;
1939 2019
1940 // If we hit something 2020 // If we hit something
@@ -1957,13 +2037,10 @@ namespace OpenSim.Region.Framework.Scenes
1957 //pos.Z -= 0.25F; 2037 //pos.Z -= 0.25F;
1958 2038
1959 } 2039 }
1960
1961 return pos;
1962 } 2040 }
1963 else 2041 else
1964 { 2042 {
1965 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2043 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1966
1967 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2044 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1968 2045
1969 // Un-comment the following line to print the raytrace results to the console. 2046 // Un-comment the following line to print the raytrace results to the console.
@@ -1972,13 +2049,12 @@ namespace OpenSim.Region.Framework.Scenes
1972 if (ei.HitTF) 2049 if (ei.HitTF)
1973 { 2050 {
1974 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2051 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1975 } else 2052 }
2053 else
1976 { 2054 {
1977 // fall back to our stupid functionality 2055 // fall back to our stupid functionality
1978 pos = RayEnd; 2056 pos = RayEnd;
1979 } 2057 }
1980
1981 return pos;
1982 } 2058 }
1983 } 2059 }
1984 else 2060 else
@@ -1989,8 +2065,12 @@ namespace OpenSim.Region.Framework.Scenes
1989 //increase height so its above the ground. 2065 //increase height so its above the ground.
1990 //should be getting the normal of the ground at the rez point and using that? 2066 //should be getting the normal of the ground at the rez point and using that?
1991 pos.Z += scale.Z / 2f; 2067 pos.Z += scale.Z / 2f;
1992 return pos; 2068// return pos;
1993 } 2069 }
2070
2071 // check against posible water intercept
2072 if (wpos.Z > pos.Z) pos = wpos;
2073 return pos;
1994 } 2074 }
1995 2075
1996 2076
@@ -2079,7 +2159,10 @@ namespace OpenSim.Region.Framework.Scenes
2079 public bool AddRestoredSceneObject( 2159 public bool AddRestoredSceneObject(
2080 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2160 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2081 { 2161 {
2082 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2162 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2163 if (result)
2164 sceneObject.IsDeleted = false;
2165 return result;
2083 } 2166 }
2084 2167
2085 /// <summary> 2168 /// <summary>
@@ -2171,6 +2254,15 @@ namespace OpenSim.Region.Framework.Scenes
2171 /// </summary> 2254 /// </summary>
2172 public void DeleteAllSceneObjects() 2255 public void DeleteAllSceneObjects()
2173 { 2256 {
2257 DeleteAllSceneObjects(false);
2258 }
2259
2260 /// <summary>
2261 /// Delete every object from the scene. This does not include attachments worn by avatars.
2262 /// </summary>
2263 public void DeleteAllSceneObjects(bool exceptNoCopy)
2264 {
2265 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2174 lock (Entities) 2266 lock (Entities)
2175 { 2267 {
2176 EntityBase[] entities = Entities.GetEntities(); 2268 EntityBase[] entities = Entities.GetEntities();
@@ -2179,11 +2271,24 @@ namespace OpenSim.Region.Framework.Scenes
2179 if (e is SceneObjectGroup) 2271 if (e is SceneObjectGroup)
2180 { 2272 {
2181 SceneObjectGroup sog = (SceneObjectGroup)e; 2273 SceneObjectGroup sog = (SceneObjectGroup)e;
2182 if (!sog.IsAttachment) 2274 if (sog != null && !sog.IsAttachment)
2183 DeleteSceneObject((SceneObjectGroup)e, false); 2275 {
2276 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2277 {
2278 DeleteSceneObject((SceneObjectGroup)e, false);
2279 }
2280 else
2281 {
2282 toReturn.Add((SceneObjectGroup)e);
2283 }
2284 }
2184 } 2285 }
2185 } 2286 }
2186 } 2287 }
2288 if (toReturn.Count > 0)
2289 {
2290 returnObjects(toReturn.ToArray(), UUID.Zero);
2291 }
2187 } 2292 }
2188 2293
2189 /// <summary> 2294 /// <summary>
@@ -2235,6 +2340,8 @@ namespace OpenSim.Region.Framework.Scenes
2235 } 2340 }
2236 2341
2237 group.DeleteGroupFromScene(silent); 2342 group.DeleteGroupFromScene(silent);
2343 if (!silent)
2344 SendKillObject(new List<uint>() { group.LocalId });
2238 2345
2239// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2346// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2240 } 2347 }
@@ -2525,7 +2632,7 @@ namespace OpenSim.Region.Framework.Scenes
2525 // If the user is banned, we won't let any of their objects 2632 // If the user is banned, we won't let any of their objects
2526 // enter. Period. 2633 // enter. Period.
2527 // 2634 //
2528 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) 2635 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2529 { 2636 {
2530 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); 2637 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2531 return false; 2638 return false;
@@ -2533,6 +2640,8 @@ namespace OpenSim.Region.Framework.Scenes
2533 2640
2534 if (newPosition != Vector3.Zero) 2641 if (newPosition != Vector3.Zero)
2535 newObject.RootPart.GroupPosition = newPosition; 2642 newObject.RootPart.GroupPosition = newPosition;
2643 if (newObject.RootPart.KeyframeMotion != null)
2644 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2536 2645
2537 if (!AddSceneObject(newObject)) 2646 if (!AddSceneObject(newObject))
2538 { 2647 {
@@ -2577,6 +2686,23 @@ namespace OpenSim.Region.Framework.Scenes
2577 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2686 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2578 public bool AddSceneObject(SceneObjectGroup sceneObject) 2687 public bool AddSceneObject(SceneObjectGroup sceneObject)
2579 { 2688 {
2689 if (sceneObject.OwnerID == UUID.Zero)
2690 {
2691 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2692 return false;
2693 }
2694
2695 // If the user is banned, we won't let any of their objects
2696 // enter. Period.
2697 //
2698 int flags = GetUserFlags(sceneObject.OwnerID);
2699 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2700 {
2701 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2702
2703 return false;
2704 }
2705
2580 // Force allocation of new LocalId 2706 // Force allocation of new LocalId
2581 // 2707 //
2582 SceneObjectPart[] parts = sceneObject.Parts; 2708 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2610,16 +2736,27 @@ namespace OpenSim.Region.Framework.Scenes
2610 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2736 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2611 2737
2612 if (AttachmentsModule != null) 2738 if (AttachmentsModule != null)
2613 AttachmentsModule.AttachObject(sp, grp, 0, false); 2739 AttachmentsModule.AttachObject(sp, grp, 0, false, false);
2614 } 2740 }
2615 else 2741 else
2616 { 2742 {
2743 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2617 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2744 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2618 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2745 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2619 } 2746 }
2747 if (sceneObject.OwnerID == UUID.Zero)
2748 {
2749 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2750 return false;
2751 }
2620 } 2752 }
2621 else 2753 else
2622 { 2754 {
2755 if (sceneObject.OwnerID == UUID.Zero)
2756 {
2757 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2758 return false;
2759 }
2623 AddRestoredSceneObject(sceneObject, true, false); 2760 AddRestoredSceneObject(sceneObject, true, false);
2624 } 2761 }
2625 2762
@@ -2636,6 +2773,24 @@ namespace OpenSim.Region.Framework.Scenes
2636 return 2; // StateSource.PrimCrossing 2773 return 2; // StateSource.PrimCrossing
2637 } 2774 }
2638 2775
2776 public int GetUserFlags(UUID user)
2777 {
2778 //Unfortunately the SP approach means that the value is cached until region is restarted
2779 /*
2780 ScenePresence sp;
2781 if (TryGetScenePresence(user, out sp))
2782 {
2783 return sp.UserFlags;
2784 }
2785 else
2786 {
2787 */
2788 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2789 if (uac == null)
2790 return 0;
2791 return uac.UserFlags;
2792 //}
2793 }
2639 #endregion 2794 #endregion
2640 2795
2641 #region Add/Remove Avatar Methods 2796 #region Add/Remove Avatar Methods
@@ -2649,7 +2804,7 @@ namespace OpenSim.Region.Framework.Scenes
2649 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2804 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2650 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2805 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2651 2806
2652// CheckHeartbeat(); 2807 CheckHeartbeat();
2653 2808
2654 ScenePresence sp = GetScenePresence(client.AgentId); 2809 ScenePresence sp = GetScenePresence(client.AgentId);
2655 2810
@@ -2703,7 +2858,13 @@ namespace OpenSim.Region.Framework.Scenes
2703 2858
2704 EventManager.TriggerOnNewClient(client); 2859 EventManager.TriggerOnNewClient(client);
2705 if (vialogin) 2860 if (vialogin)
2861 {
2706 EventManager.TriggerOnClientLogin(client); 2862 EventManager.TriggerOnClientLogin(client);
2863 // Send initial parcel data
2864 Vector3 pos = sp.AbsolutePosition;
2865 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2866 land.SendLandUpdateToClient(client);
2867 }
2707 2868
2708 return sp; 2869 return sp;
2709 } 2870 }
@@ -2792,19 +2953,12 @@ namespace OpenSim.Region.Framework.Scenes
2792 // and the scene presence and the client, if they exist 2953 // and the scene presence and the client, if they exist
2793 try 2954 try
2794 { 2955 {
2795 // We need to wait for the client to make UDP contact first. 2956 ScenePresence sp = GetScenePresence(agentID);
2796 // It's the UDP contact that creates the scene presence 2957 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2797 ScenePresence sp = WaitGetScenePresence(agentID); 2958
2798 if (sp != null) 2959 if (sp != null)
2799 {
2800 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2801
2802 sp.ControllingClient.Close(); 2960 sp.ControllingClient.Close();
2803 } 2961
2804 else
2805 {
2806 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2807 }
2808 // BANG! SLASH! 2962 // BANG! SLASH!
2809 m_authenticateHandler.RemoveCircuit(agentID); 2963 m_authenticateHandler.RemoveCircuit(agentID);
2810 2964
@@ -2849,6 +3003,8 @@ namespace OpenSim.Region.Framework.Scenes
2849 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3003 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2850 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 3004 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2851 3005
3006 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
3007
2852 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 3008 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2853 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3009 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2854 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3010 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2905,6 +3061,7 @@ namespace OpenSim.Region.Framework.Scenes
2905 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3061 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2906 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3062 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2907 client.OnCopyInventoryItem += CopyInventoryItem; 3063 client.OnCopyInventoryItem += CopyInventoryItem;
3064 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2908 client.OnMoveInventoryItem += MoveInventoryItem; 3065 client.OnMoveInventoryItem += MoveInventoryItem;
2909 client.OnRemoveInventoryItem += RemoveInventoryItem; 3066 client.OnRemoveInventoryItem += RemoveInventoryItem;
2910 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3067 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2976,6 +3133,8 @@ namespace OpenSim.Region.Framework.Scenes
2976 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3133 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
2977 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3134 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
2978 3135
3136 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3137
2979 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3138 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2980 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3139 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2981 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3140 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3078,7 +3237,7 @@ namespace OpenSim.Region.Framework.Scenes
3078 /// </summary> 3237 /// </summary>
3079 /// <param name="agentId">The avatar's Unique ID</param> 3238 /// <param name="agentId">The avatar's Unique ID</param>
3080 /// <param name="client">The IClientAPI for the client</param> 3239 /// <param name="client">The IClientAPI for the client</param>
3081 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3240 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3082 { 3241 {
3083 if (EntityTransferModule != null) 3242 if (EntityTransferModule != null)
3084 { 3243 {
@@ -3089,6 +3248,7 @@ namespace OpenSim.Region.Framework.Scenes
3089 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3248 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3090 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3249 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3091 } 3250 }
3251 return false;
3092 } 3252 }
3093 3253
3094 /// <summary> 3254 /// <summary>
@@ -3198,6 +3358,16 @@ namespace OpenSim.Region.Framework.Scenes
3198 /// <param name="flags"></param> 3358 /// <param name="flags"></param>
3199 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3359 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3200 { 3360 {
3361 //Add half the avatar's height so that the user doesn't fall through prims
3362 ScenePresence presence;
3363 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3364 {
3365 if (presence.Appearance != null)
3366 {
3367 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3368 }
3369 }
3370
3201 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3371 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3202 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3372 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3203 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3373 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3314,6 +3484,7 @@ namespace OpenSim.Region.Framework.Scenes
3314 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3484 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3315 3485
3316 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3486 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3487 m_log.Debug("[Scene] The avatar has left the building");
3317 } 3488 }
3318 catch (Exception e) 3489 catch (Exception e)
3319 { 3490 {
@@ -3515,13 +3686,16 @@ namespace OpenSim.Region.Framework.Scenes
3515 sp = null; 3686 sp = null;
3516 } 3687 }
3517 3688
3518 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3519 3689
3520 //On login test land permisions 3690 //On login test land permisions
3521 if (vialogin) 3691 if (vialogin)
3522 { 3692 {
3523 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3693 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3694 if (cache != null)
3695 cache.Remove(agent.firstname + " " + agent.lastname);
3696 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3524 { 3697 {
3698 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3525 return false; 3699 return false;
3526 } 3700 }
3527 } 3701 }
@@ -3544,9 +3718,15 @@ namespace OpenSim.Region.Framework.Scenes
3544 3718
3545 try 3719 try
3546 { 3720 {
3547 if (!AuthorizeUser(agent, out reason)) 3721 // Always check estate if this is a login. Always
3548 return false; 3722 // check if banned regions are to be blacked out.
3549 } catch (Exception e) 3723 if (vialogin || (!m_seeIntoBannedRegion))
3724 {
3725 if (!AuthorizeUser(agent, out reason))
3726 return false;
3727 }
3728 }
3729 catch (Exception e)
3550 { 3730 {
3551 m_log.ErrorFormat( 3731 m_log.ErrorFormat(
3552 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3732 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@@ -3677,6 +3857,8 @@ namespace OpenSim.Region.Framework.Scenes
3677 } 3857 }
3678 3858
3679 // Honor parcel landing type and position. 3859 // Honor parcel landing type and position.
3860 /*
3861 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3680 if (land != null) 3862 if (land != null)
3681 { 3863 {
3682 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3864 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3684,25 +3866,34 @@ namespace OpenSim.Region.Framework.Scenes
3684 agent.startpos = land.LandData.UserLocation; 3866 agent.startpos = land.LandData.UserLocation;
3685 } 3867 }
3686 } 3868 }
3869 */// This is now handled properly in ScenePresence.MakeRootAgent
3687 } 3870 }
3688 3871
3689 return true; 3872 return true;
3690 } 3873 }
3691 3874
3692 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3875 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3693 { 3876 {
3694 bool banned = land.IsBannedFromLand(agent.AgentID); 3877 reason = String.Empty;
3695 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3878 if (Permissions.IsGod(agentID))
3879 return true;
3880
3881 ILandObject land = LandChannel.GetLandObject(posX, posY);
3882 if (land == null)
3883 return false;
3884
3885 bool banned = land.IsBannedFromLand(agentID);
3886 bool restricted = land.IsRestrictedFromLand(agentID);
3696 3887
3697 if (banned || restricted) 3888 if (banned || restricted)
3698 { 3889 {
3699 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3890 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3700 if (nearestParcel != null) 3891 if (nearestParcel != null)
3701 { 3892 {
3702 //Move agent to nearest allowed 3893 //Move agent to nearest allowed
3703 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3894 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3704 agent.startpos.X = newPosition.X; 3895 posX = newPosition.X;
3705 agent.startpos.Y = newPosition.Y; 3896 posY = newPosition.Y;
3706 } 3897 }
3707 else 3898 else
3708 { 3899 {
@@ -3764,7 +3955,7 @@ namespace OpenSim.Region.Framework.Scenes
3764 3955
3765 if (!m_strictAccessControl) return true; 3956 if (!m_strictAccessControl) return true;
3766 if (Permissions.IsGod(agent.AgentID)) return true; 3957 if (Permissions.IsGod(agent.AgentID)) return true;
3767 3958
3768 if (AuthorizationService != null) 3959 if (AuthorizationService != null)
3769 { 3960 {
3770 if (!AuthorizationService.IsAuthorizedForRegion( 3961 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3779,7 +3970,7 @@ namespace OpenSim.Region.Framework.Scenes
3779 3970
3780 if (RegionInfo.EstateSettings != null) 3971 if (RegionInfo.EstateSettings != null)
3781 { 3972 {
3782 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 3973 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3783 { 3974 {
3784 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3975 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3785 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3976 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3969,6 +4160,15 @@ namespace OpenSim.Region.Framework.Scenes
3969 4160
3970 // XPTO: if this agent is not allowed here as root, always return false 4161 // XPTO: if this agent is not allowed here as root, always return false
3971 4162
4163 // We have to wait until the viewer contacts this region after receiving EAC.
4164 // That calls AddNewClient, which finally creates the ScenePresence
4165 int flags = GetUserFlags(cAgentData.AgentID);
4166 if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4167 {
4168 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4169 return false;
4170 }
4171
3972 // TODO: This check should probably be in QueryAccess(). 4172 // TODO: This check should probably be in QueryAccess().
3973 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4173 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3974 if (nearestParcel == null) 4174 if (nearestParcel == null)
@@ -4062,12 +4262,22 @@ namespace OpenSim.Region.Framework.Scenes
4062 return false; 4262 return false;
4063 } 4263 }
4064 4264
4265 public bool IncomingCloseAgent(UUID agentID)
4266 {
4267 return IncomingCloseAgent(agentID, false);
4268 }
4269
4270 public bool IncomingCloseChildAgent(UUID agentID)
4271 {
4272 return IncomingCloseAgent(agentID, true);
4273 }
4274
4065 /// <summary> 4275 /// <summary>
4066 /// Tell a single agent to disconnect from the region. 4276 /// Tell a single agent to disconnect from the region.
4067 /// </summary> 4277 /// </summary>
4068 /// <param name="regionHandle"></param>
4069 /// <param name="agentID"></param> 4278 /// <param name="agentID"></param>
4070 public bool IncomingCloseAgent(UUID agentID) 4279 /// <param name="childOnly"></param>
4280 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
4071 { 4281 {
4072 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4282 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4073 4283
@@ -4688,35 +4898,81 @@ namespace OpenSim.Region.Framework.Scenes
4688 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); 4898 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4689 } 4899 }
4690 4900
4691 public int GetHealth() 4901 public int GetHealth(out int flags, out string message)
4692 { 4902 {
4693 // Returns: 4903 // Returns:
4694 // 1 = sim is up and accepting http requests. The heartbeat has 4904 // 1 = sim is up and accepting http requests. The heartbeat has
4695 // stopped and the sim is probably locked up, but a remote 4905 // stopped and the sim is probably locked up, but a remote
4696 // admin restart may succeed 4906 // admin restart may succeed
4697 // 4907 //
4698 // 2 = Sim is up and the heartbeat is running. The sim is likely 4908 // 2 = Sim is up and the heartbeat is running. The sim is likely
4699 // usable for people within and logins _may_ work 4909 // usable for people within
4910 //
4911 // 3 = Sim is up and one packet thread is running. Sim is
4912 // unstable and will not accept new logins
4913 //
4914 // 4 = Sim is up and both packet threads are running. Sim is
4915 // likely usable
4700 // 4916 //
4701 // 3 = We have seen a new user enter within the past 4 minutes 4917 // 5 = We have seen a new user enter within the past 4 minutes
4702 // which can be seen as positive confirmation of sim health 4918 // which can be seen as positive confirmation of sim health
4703 // 4919 //
4920
4921 flags = 0;
4922 message = String.Empty;
4923
4924 CheckHeartbeat();
4925
4926 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4927 {
4928 // We're still starting
4929 // 0 means "in startup", it can't happen another way, since
4930 // to get here, we must be able to accept http connections
4931 return 0;
4932 }
4933
4704 int health=1; // Start at 1, means we're up 4934 int health=1; // Start at 1, means we're up
4705 4935
4706 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 4936 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4707 health += 1; 4937 {
4938 health+=1;
4939 flags |= 1;
4940 }
4941
4942 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4943 {
4944 health+=1;
4945 flags |= 2;
4946 }
4947
4948 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4949 {
4950 health+=1;
4951 flags |= 4;
4952 }
4708 else 4953 else
4954 {
4955int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4956System.Diagnostics.Process proc = new System.Diagnostics.Process();
4957proc.EnableRaisingEvents=false;
4958proc.StartInfo.FileName = "/bin/kill";
4959proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4960proc.Start();
4961proc.WaitForExit();
4962Thread.Sleep(1000);
4963Environment.Exit(1);
4964 }
4965
4966 if (flags != 7)
4709 return health; 4967 return health;
4710 4968
4711 // A login in the last 4 mins? We can't be doing too badly 4969 // A login in the last 4 mins? We can't be doing too badly
4712 // 4970 //
4713 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4971 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4714 health++; 4972 health++;
4715 else 4973 else
4716 return health; 4974 return health;
4717 4975
4718// CheckHeartbeat();
4719
4720 return health; 4976 return health;
4721 } 4977 }
4722 4978
@@ -4804,7 +5060,7 @@ namespace OpenSim.Region.Framework.Scenes
4804 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 5060 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4805 if (wasUsingPhysics) 5061 if (wasUsingPhysics)
4806 { 5062 {
4807 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 5063 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
4808 } 5064 }
4809 } 5065 }
4810 5066
@@ -4903,14 +5159,14 @@ namespace OpenSim.Region.Framework.Scenes
4903 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5159 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
4904 } 5160 }
4905 5161
4906// private void CheckHeartbeat() 5162 private void CheckHeartbeat()
4907// { 5163 {
4908// if (m_firstHeartbeat) 5164 if (m_firstHeartbeat)
4909// return; 5165 return;
4910// 5166
4911// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5167 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
4912// StartTimer(); 5168 Start();
4913// } 5169 }
4914 5170
4915 public override ISceneObject DeserializeObject(string representation) 5171 public override ISceneObject DeserializeObject(string representation)
4916 { 5172 {
@@ -4922,9 +5178,14 @@ namespace OpenSim.Region.Framework.Scenes
4922 get { return m_allowScriptCrossings; } 5178 get { return m_allowScriptCrossings; }
4923 } 5179 }
4924 5180
4925 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5181 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
4926 { 5182 {
4927 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5183 return GetNearestAllowedPosition(avatar, null);
5184 }
5185
5186 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5187 {
5188 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4928 5189
4929 if (nearestParcel != null) 5190 if (nearestParcel != null)
4930 { 5191 {
@@ -4933,10 +5194,7 @@ namespace OpenSim.Region.Framework.Scenes
4933 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5194 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4934 if (nearestPoint != null) 5195 if (nearestPoint != null)
4935 { 5196 {
4936// m_log.DebugFormat( 5197 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4937// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
4938// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
4939
4940 return nearestPoint.Value; 5198 return nearestPoint.Value;
4941 } 5199 }
4942 5200
@@ -4946,17 +5204,20 @@ namespace OpenSim.Region.Framework.Scenes
4946 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5204 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4947 if (nearestPoint != null) 5205 if (nearestPoint != null)
4948 { 5206 {
4949// m_log.DebugFormat( 5207 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4950// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
4951
4952 return nearestPoint.Value; 5208 return nearestPoint.Value;
4953 } 5209 }
4954 5210
4955 //Ultimate backup if we have no idea where they are 5211 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
4956// m_log.DebugFormat( 5212 if (dest != excludeParcel)
4957// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5213 {
5214 // Ultimate backup if we have no idea where they are and
5215 // the last allowed position was in another parcel
5216 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5217 return avatar.lastKnownAllowedPosition;
5218 }
4958 5219
4959 return avatar.lastKnownAllowedPosition; 5220 // else fall through to region edge
4960 } 5221 }
4961 5222
4962 //Go to the edge, this happens in teleporting to a region with no available parcels 5223 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -4990,13 +5251,18 @@ namespace OpenSim.Region.Framework.Scenes
4990 5251
4991 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5252 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4992 { 5253 {
5254 return GetNearestAllowedParcel(avatarId, x, y, null);
5255 }
5256
5257 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5258 {
4993 List<ILandObject> all = AllParcels(); 5259 List<ILandObject> all = AllParcels();
4994 float minParcelDistance = float.MaxValue; 5260 float minParcelDistance = float.MaxValue;
4995 ILandObject nearestParcel = null; 5261 ILandObject nearestParcel = null;
4996 5262
4997 foreach (var parcel in all) 5263 foreach (var parcel in all)
4998 { 5264 {
4999 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5265 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5000 { 5266 {
5001 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5267 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5002 if (parcelDistance < minParcelDistance) 5268 if (parcelDistance < minParcelDistance)
@@ -5238,7 +5504,55 @@ namespace OpenSim.Region.Framework.Scenes
5238 mapModule.GenerateMaptile(); 5504 mapModule.GenerateMaptile();
5239 } 5505 }
5240 5506
5241 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5507// public void CleanDroppedAttachments()
5508// {
5509// List<SceneObjectGroup> objectsToDelete =
5510// new List<SceneObjectGroup>();
5511//
5512// lock (m_cleaningAttachments)
5513// {
5514// ForEachSOG(delegate (SceneObjectGroup grp)
5515// {
5516// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5517// {
5518// UUID agentID = grp.OwnerID;
5519// if (agentID == UUID.Zero)
5520// {
5521// objectsToDelete.Add(grp);
5522// return;
5523// }
5524//
5525// ScenePresence sp = GetScenePresence(agentID);
5526// if (sp == null)
5527// {
5528// objectsToDelete.Add(grp);
5529// return;
5530// }
5531// }
5532// });
5533// }
5534//
5535// foreach (SceneObjectGroup grp in objectsToDelete)
5536// {
5537// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5538// DeleteSceneObject(grp, true);
5539// }
5540// }
5541
5542 public void ThreadAlive(int threadCode)
5543 {
5544 switch(threadCode)
5545 {
5546 case 1: // Incoming
5547 m_lastIncoming = Util.EnvironmentTickCount();
5548 break;
5549 case 2: // Incoming
5550 m_lastOutgoing = Util.EnvironmentTickCount();
5551 break;
5552 }
5553 }
5554
5555 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5242 { 5556 {
5243 RegenerateMaptile(); 5557 RegenerateMaptile();
5244 5558
@@ -5266,6 +5580,8 @@ namespace OpenSim.Region.Framework.Scenes
5266 /// <returns></returns> 5580 /// <returns></returns>
5267 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5581 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5268 { 5582 {
5583 reason = "You are banned from the region";
5584
5269 if (EntityTransferModule.IsInTransit(agentID)) 5585 if (EntityTransferModule.IsInTransit(agentID))
5270 { 5586 {
5271 reason = "Agent is still in transit from this region"; 5587 reason = "Agent is still in transit from this region";
@@ -5277,6 +5593,12 @@ namespace OpenSim.Region.Framework.Scenes
5277 return false; 5593 return false;
5278 } 5594 }
5279 5595
5596 if (Permissions.IsGod(agentID))
5597 {
5598 reason = String.Empty;
5599 return true;
5600 }
5601
5280 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5602 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5281 // However, the long term fix is to make sure root agent count is always accurate. 5603 // However, the long term fix is to make sure root agent count is always accurate.
5282 m_sceneGraph.RecalculateStats(); 5604 m_sceneGraph.RecalculateStats();
@@ -5297,6 +5619,41 @@ namespace OpenSim.Region.Framework.Scenes
5297 } 5619 }
5298 } 5620 }
5299 5621
5622 ScenePresence presence = GetScenePresence(agentID);
5623 IClientAPI client = null;
5624 AgentCircuitData aCircuit = null;
5625
5626 if (presence != null)
5627 {
5628 client = presence.ControllingClient;
5629 if (client != null)
5630 aCircuit = client.RequestClientInfo();
5631 }
5632
5633 // We may be called before there is a presence or a client.
5634 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5635 if (client == null)
5636 {
5637 aCircuit = new AgentCircuitData();
5638 aCircuit.AgentID = agentID;
5639 aCircuit.firstname = String.Empty;
5640 aCircuit.lastname = String.Empty;
5641 }
5642
5643 try
5644 {
5645 if (!AuthorizeUser(aCircuit, out reason))
5646 {
5647 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5648 return false;
5649 }
5650 }
5651 catch (Exception e)
5652 {
5653 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5654 return false;
5655 }
5656
5300 if (position == Vector3.Zero) // Teleport 5657 if (position == Vector3.Zero) // Teleport
5301 { 5658 {
5302 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5659 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5325,13 +5682,46 @@ namespace OpenSim.Region.Framework.Scenes
5325 } 5682 }
5326 } 5683 }
5327 } 5684 }
5685
5686 float posX = 128.0f;
5687 float posY = 128.0f;
5688
5689 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5690 {
5691 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5692 return false;
5693 }
5694 }
5695 else // Walking
5696 {
5697 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5698 if (land == null)
5699 return false;
5700
5701 bool banned = land.IsBannedFromLand(agentID);
5702 bool restricted = land.IsRestrictedFromLand(agentID);
5703
5704 if (banned || restricted)
5705 return false;
5328 } 5706 }
5329 5707
5330 reason = String.Empty; 5708 reason = String.Empty;
5331 return true; 5709 return true;
5332 } 5710 }
5333 5711
5334 /// <summary> 5712 public void StartTimerWatchdog()
5713 {
5714 m_timerWatchdog.Interval = 1000;
5715 m_timerWatchdog.Elapsed += TimerWatchdog;
5716 m_timerWatchdog.AutoReset = true;
5717 m_timerWatchdog.Start();
5718 }
5719
5720 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5721 {
5722 CheckHeartbeat();
5723 }
5724
5335 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5725 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5336 /// autopilot that moves an avatar to a sit target!. 5726 /// autopilot that moves an avatar to a sit target!.
5337 /// </summary> 5727 /// </summary>
@@ -5409,5 +5799,10 @@ namespace OpenSim.Region.Framework.Scenes
5409 m_SpawnPoint = 1; 5799 m_SpawnPoint = 1;
5410 return m_SpawnPoint - 1; 5800 return m_SpawnPoint - 1;
5411 } 5801 }
5802
5803 private void HandleGcCollect(string module, string[] args)
5804 {
5805 GC.Collect();
5806 }
5412 } 5807 }
5413} 5808}