diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 787 |
1 files changed, 591 insertions, 196 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eb4ba41..f7d74db 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -128,6 +128,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
128 | // TODO: need to figure out how allow client agents but deny | 128 | // TODO: need to figure out how allow client agents but deny |
129 | // root agents when ACL denies access to root agent | 129 | // root agents when ACL denies access to root agent |
130 | public bool m_strictAccessControl = true; | 130 | public bool m_strictAccessControl = true; |
131 | public bool m_seeIntoBannedRegion = false; | ||
131 | public int MaxUndoCount = 5; | 132 | public int MaxUndoCount = 5; |
132 | 133 | ||
133 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 134 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
@@ -144,12 +145,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | 145 | ||
145 | protected int m_splitRegionID; | 146 | protected int m_splitRegionID; |
146 | protected Timer m_restartWaitTimer = new Timer(); | 147 | protected Timer m_restartWaitTimer = new Timer(); |
148 | protected Timer m_timerWatchdog = new Timer(); | ||
147 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 149 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
148 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 150 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
149 | protected string m_simulatorVersion = "OpenSimulator Server"; | 151 | protected string m_simulatorVersion = "OpenSimulator Server"; |
150 | protected ModuleLoader m_moduleLoader; | 152 | protected ModuleLoader m_moduleLoader; |
151 | protected AgentCircuitManager m_authenticateHandler; | 153 | protected AgentCircuitManager m_authenticateHandler; |
152 | protected SceneCommunicationService m_sceneGridService; | 154 | protected SceneCommunicationService m_sceneGridService; |
155 | protected ISnmpModule m_snmpService = null; | ||
153 | 156 | ||
154 | protected ISimulationDataService m_SimulationDataService; | 157 | protected ISimulationDataService m_SimulationDataService; |
155 | protected IEstateDataService m_EstateDataService; | 158 | protected IEstateDataService m_EstateDataService; |
@@ -211,7 +214,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | private int m_update_events = 1; | 214 | private int m_update_events = 1; |
212 | private int m_update_backup = 200; | 215 | private int m_update_backup = 200; |
213 | private int m_update_terrain = 50; | 216 | private int m_update_terrain = 50; |
214 | // private int m_update_land = 1; | 217 | private int m_update_land = 10; |
215 | private int m_update_coarse_locations = 50; | 218 | private int m_update_coarse_locations = 50; |
216 | 219 | ||
217 | private int agentMS; | 220 | private int agentMS; |
@@ -224,13 +227,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
224 | private int backupMS; | 227 | private int backupMS; |
225 | private int terrainMS; | 228 | private int terrainMS; |
226 | private int landMS; | 229 | private int landMS; |
227 | private int spareMS; | ||
228 | 230 | ||
229 | /// <summary> | 231 | /// <summary> |
230 | /// Tick at which the last frame was processed. | 232 | /// Tick at which the last frame was processed. |
231 | /// </summary> | 233 | /// </summary> |
232 | private int m_lastFrameTick; | 234 | private int m_lastFrameTick; |
233 | 235 | ||
236 | public bool CombineRegions = false; | ||
234 | /// <summary> | 237 | /// <summary> |
235 | /// Tick at which the last maintenance run occurred. | 238 | /// Tick at which the last maintenance run occurred. |
236 | /// </summary> | 239 | /// </summary> |
@@ -261,6 +264,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
261 | /// </summary> | 264 | /// </summary> |
262 | private int m_LastLogin; | 265 | private int m_LastLogin; |
263 | 266 | ||
267 | private int m_lastIncoming; | ||
268 | private int m_lastOutgoing; | ||
269 | private int m_hbRestarts = 0; | ||
270 | |||
271 | |||
264 | /// <summary> | 272 | /// <summary> |
265 | /// Thread that runs the scene loop. | 273 | /// Thread that runs the scene loop. |
266 | /// </summary> | 274 | /// </summary> |
@@ -276,7 +284,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
276 | private volatile bool m_shuttingDown; | 284 | private volatile bool m_shuttingDown; |
277 | 285 | ||
278 | // private int m_lastUpdate; | 286 | // private int m_lastUpdate; |
279 | // private bool m_firstHeartbeat = true; | 287 | private bool m_firstHeartbeat = true; |
280 | 288 | ||
281 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 289 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
282 | private bool m_reprioritizationEnabled = true; | 290 | private bool m_reprioritizationEnabled = true; |
@@ -321,6 +329,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | get { return m_sceneGridService; } | 329 | get { return m_sceneGridService; } |
322 | } | 330 | } |
323 | 331 | ||
332 | public ISnmpModule SnmpService | ||
333 | { | ||
334 | get | ||
335 | { | ||
336 | if (m_snmpService == null) | ||
337 | { | ||
338 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
339 | } | ||
340 | |||
341 | return m_snmpService; | ||
342 | } | ||
343 | } | ||
344 | |||
324 | public ISimulationDataService SimulationDataService | 345 | public ISimulationDataService SimulationDataService |
325 | { | 346 | { |
326 | get | 347 | get |
@@ -620,6 +641,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
620 | m_SimulationDataService = simDataService; | 641 | m_SimulationDataService = simDataService; |
621 | m_EstateDataService = estateDataService; | 642 | m_EstateDataService = estateDataService; |
622 | m_regionHandle = RegionInfo.RegionHandle; | 643 | m_regionHandle = RegionInfo.RegionHandle; |
644 | m_lastIncoming = 0; | ||
645 | m_lastOutgoing = 0; | ||
623 | 646 | ||
624 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 647 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
625 | m_asyncSceneObjectDeleter.Enabled = true; | 648 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -700,122 +723,131 @@ namespace OpenSim.Region.Framework.Scenes | |||
700 | 723 | ||
701 | // Region config overrides global config | 724 | // Region config overrides global config |
702 | // | 725 | // |
703 | if (m_config.Configs["Startup"] != null) | 726 | try |
704 | { | 727 | { |
705 | IConfig startupConfig = m_config.Configs["Startup"]; | 728 | if (m_config.Configs["Startup"] != null) |
706 | |||
707 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | ||
708 | |||
709 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | ||
710 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | ||
711 | if (!m_useBackup) | ||
712 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | ||
713 | |||
714 | //Animation states | ||
715 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
716 | |||
717 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
718 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
719 | |||
720 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | ||
721 | if (RegionInfo.NonphysPrimMax > 0) | ||
722 | { | 729 | { |
723 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 730 | IConfig startupConfig = m_config.Configs["Startup"]; |
724 | } | ||
725 | 731 | ||
726 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 732 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
727 | 733 | ||
728 | if (RegionInfo.PhysPrimMax > 0) | 734 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
729 | { | 735 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
730 | m_maxPhys = RegionInfo.PhysPrimMax; | 736 | if (!m_useBackup) |
731 | } | 737 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
732 | 738 | ||
733 | // Here, if clamping is requested in either global or | 739 | //Animation states |
734 | // local config, it will be used | 740 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
735 | // | ||
736 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | ||
737 | if (RegionInfo.ClampPrimSize) | ||
738 | { | ||
739 | m_clampPrimSize = true; | ||
740 | } | ||
741 | 741 | ||
742 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | 742 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
743 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 743 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
744 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | ||
745 | m_dontPersistBefore = | ||
746 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | ||
747 | m_dontPersistBefore *= 10000000; | ||
748 | m_persistAfter = | ||
749 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
750 | m_persistAfter *= 10000000; | ||
751 | 744 | ||
752 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 745 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
746 | if (RegionInfo.NonphysPrimMax > 0) | ||
747 | { | ||
748 | m_maxNonphys = RegionInfo.NonphysPrimMax; | ||
749 | } | ||
753 | 750 | ||
754 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | 751 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
755 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
756 | 752 | ||
757 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 753 | if (RegionInfo.PhysPrimMax > 0) |
758 | if (packetConfig != null) | 754 | { |
759 | { | 755 | m_maxPhys = RegionInfo.PhysPrimMax; |
760 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | 756 | } |
761 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | ||
762 | } | ||
763 | 757 | ||
764 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 758 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); |
759 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
765 | 760 | ||
766 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 761 | // Here, if clamping is requested in either global or |
767 | if (m_generateMaptiles) | 762 | // local config, it will be used |
768 | { | 763 | // |
769 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | 764 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); |
770 | if (maptileRefresh != 0) | 765 | if (RegionInfo.ClampPrimSize) |
771 | { | 766 | { |
772 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 767 | m_clampPrimSize = true; |
773 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
774 | m_mapGenerationTimer.AutoReset = true; | ||
775 | m_mapGenerationTimer.Start(); | ||
776 | } | 768 | } |
777 | } | ||
778 | else | ||
779 | { | ||
780 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
781 | UUID tileID; | ||
782 | 769 | ||
783 | if (UUID.TryParse(tile, out tileID)) | 770 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
771 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | ||
772 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | ||
773 | m_dontPersistBefore = | ||
774 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | ||
775 | m_dontPersistBefore *= 10000000; | ||
776 | m_persistAfter = | ||
777 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
778 | m_persistAfter *= 10000000; | ||
779 | |||
780 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | ||
781 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
782 | |||
783 | IConfig packetConfig = m_config.Configs["PacketPool"]; | ||
784 | if (packetConfig != null) | ||
784 | { | 785 | { |
785 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 786 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
787 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | ||
786 | } | 788 | } |
787 | } | ||
788 | 789 | ||
789 | string grant = startupConfig.GetString("AllowedClients", String.Empty); | 790 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
790 | if (grant.Length > 0) | 791 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); |
791 | { | 792 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); |
792 | foreach (string viewer in grant.Split('|')) | 793 | |
794 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | ||
795 | if (m_generateMaptiles) | ||
793 | { | 796 | { |
794 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 797 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
798 | if (maptileRefresh != 0) | ||
799 | { | ||
800 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | ||
801 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
802 | m_mapGenerationTimer.AutoReset = true; | ||
803 | m_mapGenerationTimer.Start(); | ||
804 | } | ||
795 | } | 805 | } |
796 | } | 806 | else |
807 | { | ||
808 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
809 | UUID tileID; | ||
797 | 810 | ||
798 | grant = startupConfig.GetString("BannedClients", String.Empty); | 811 | if (UUID.TryParse(tile, out tileID)) |
799 | if (grant.Length > 0) | 812 | { |
800 | { | 813 | RegionInfo.RegionSettings.TerrainImageID = tileID; |
801 | foreach (string viewer in grant.Split('|')) | 814 | } |
815 | } | ||
816 | |||
817 | string grant = startupConfig.GetString("AllowedClients", String.Empty); | ||
818 | if (grant.Length > 0) | ||
802 | { | 819 | { |
803 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 820 | foreach (string viewer in grant.Split(',')) |
821 | { | ||
822 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | ||
823 | } | ||
804 | } | 824 | } |
805 | } | ||
806 | 825 | ||
807 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 826 | grant = startupConfig.GetString("BannedClients", String.Empty); |
808 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 827 | if (grant.Length > 0) |
809 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 828 | { |
810 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 829 | foreach (string viewer in grant.Split(',')) |
811 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 830 | { |
812 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | 831 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
813 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | 832 | } |
814 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | 833 | } |
815 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
816 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
817 | 834 | ||
818 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | 835 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
836 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | ||
837 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | ||
838 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | ||
839 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | ||
840 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
841 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
842 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
843 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
844 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
845 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | ||
846 | } | ||
847 | } | ||
848 | catch (Exception e) | ||
849 | { | ||
850 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
819 | } | 851 | } |
820 | 852 | ||
821 | #endregion Region Config | 853 | #endregion Region Config |
@@ -850,6 +882,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
850 | StatsReporter = new SimStatsReporter(this); | 882 | StatsReporter = new SimStatsReporter(this); |
851 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 883 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
852 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 884 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
885 | |||
886 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
853 | } | 887 | } |
854 | 888 | ||
855 | public Scene(RegionInfo regInfo) : base(regInfo) | 889 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1252,7 +1286,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1252 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1286 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1253 | if (m_heartbeatThread != null) | 1287 | if (m_heartbeatThread != null) |
1254 | { | 1288 | { |
1289 | m_hbRestarts++; | ||
1290 | if(m_hbRestarts > 10) | ||
1291 | Environment.Exit(1); | ||
1292 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1293 | |||
1294 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1295 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1296 | //proc.EnableRaisingEvents=false; | ||
1297 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1298 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1299 | //proc.Start(); | ||
1300 | //proc.WaitForExit(); | ||
1301 | //Thread.Sleep(1000); | ||
1302 | //Environment.Exit(1); | ||
1255 | m_heartbeatThread.Abort(); | 1303 | m_heartbeatThread.Abort(); |
1304 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1256 | m_heartbeatThread = null; | 1305 | m_heartbeatThread = null; |
1257 | } | 1306 | } |
1258 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1307 | // m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1399,16 +1448,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1399 | endFrame = Frame + frames; | 1448 | endFrame = Frame + frames; |
1400 | 1449 | ||
1401 | float physicsFPS = 0f; | 1450 | float physicsFPS = 0f; |
1402 | int previousFrameTick, tmpMS; | 1451 | int tmpMS; |
1403 | int maintc = Util.EnvironmentTickCount(); | 1452 | int previousFrameTick; |
1453 | int maintc; | ||
1454 | int sleepMS; | ||
1455 | int framestart; | ||
1404 | 1456 | ||
1405 | while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) | 1457 | while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) |
1406 | { | 1458 | { |
1459 | framestart = Util.EnvironmentTickCount(); | ||
1407 | ++Frame; | 1460 | ++Frame; |
1408 | 1461 | ||
1409 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1462 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1410 | 1463 | ||
1411 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1464 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1412 | 1465 | ||
1413 | try | 1466 | try |
1414 | { | 1467 | { |
@@ -1460,6 +1513,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1460 | m_sceneGraph.UpdatePresences(); | 1513 | m_sceneGraph.UpdatePresences(); |
1461 | 1514 | ||
1462 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1515 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1516 | |||
1463 | 1517 | ||
1464 | // Delete temp-on-rez stuff | 1518 | // Delete temp-on-rez stuff |
1465 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1519 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1541,34 +1595,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1541 | 1595 | ||
1542 | Watchdog.UpdateThread(); | 1596 | Watchdog.UpdateThread(); |
1543 | 1597 | ||
1598 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1599 | |||
1600 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1601 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1602 | StatsReporter.AddFPS(1); | ||
1603 | |||
1604 | StatsReporter.addAgentMS(agentMS); | ||
1605 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1606 | StatsReporter.addOtherMS(otherMS); | ||
1607 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1608 | |||
1544 | previousFrameTick = m_lastFrameTick; | 1609 | previousFrameTick = m_lastFrameTick; |
1545 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1610 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1546 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1611 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1547 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1612 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1548 | 1613 | ||
1614 | m_firstHeartbeat = false; | ||
1615 | |||
1616 | sleepMS = Util.EnvironmentTickCount(); | ||
1617 | |||
1549 | if (tmpMS > 0) | 1618 | if (tmpMS > 0) |
1550 | { | ||
1551 | Thread.Sleep(tmpMS); | 1619 | Thread.Sleep(tmpMS); |
1552 | spareMS += tmpMS; | ||
1553 | } | ||
1554 | |||
1555 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | ||
1556 | maintc = Util.EnvironmentTickCount(); | ||
1557 | 1620 | ||
1558 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1621 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1622 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1623 | StatsReporter.addSleepMS(sleepMS); | ||
1624 | StatsReporter.addFrameMS(frameMS); | ||
1559 | 1625 | ||
1560 | // if (Frame%m_update_avatars == 0) | 1626 | // if (Frame%m_update_avatars == 0) |
1561 | // UpdateInWorldTime(); | 1627 | // UpdateInWorldTime(); |
1562 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1563 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1564 | StatsReporter.AddFPS(1); | ||
1565 | 1628 | ||
1566 | StatsReporter.addFrameMS(frameMS); | ||
1567 | StatsReporter.addAgentMS(agentMS); | ||
1568 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1569 | StatsReporter.addOtherMS(otherMS); | ||
1570 | StatsReporter.AddSpareMS(spareMS); | ||
1571 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1572 | 1629 | ||
1573 | // Optionally warn if a frame takes double the amount of time that it should. | 1630 | // Optionally warn if a frame takes double the amount of time that it should. |
1574 | if (DebugUpdates | 1631 | if (DebugUpdates |
@@ -1596,9 +1653,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1596 | 1653 | ||
1597 | private void CheckAtTargets() | 1654 | private void CheckAtTargets() |
1598 | { | 1655 | { |
1599 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1656 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1600 | lock (m_groupsWithTargets) | 1657 | lock (m_groupsWithTargets) |
1601 | objs = m_groupsWithTargets.Values; | 1658 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1602 | 1659 | ||
1603 | foreach (SceneObjectGroup entry in objs) | 1660 | foreach (SceneObjectGroup entry in objs) |
1604 | entry.checkAtTargets(); | 1661 | entry.checkAtTargets(); |
@@ -1679,7 +1736,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1679 | msg.fromAgentName = "Server"; | 1736 | msg.fromAgentName = "Server"; |
1680 | msg.dialog = (byte)19; // Object msg | 1737 | msg.dialog = (byte)19; // Object msg |
1681 | msg.fromGroup = false; | 1738 | msg.fromGroup = false; |
1682 | msg.offline = (byte)0; | 1739 | msg.offline = (byte)1; |
1683 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1740 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1684 | msg.Position = Vector3.Zero; | 1741 | msg.Position = Vector3.Zero; |
1685 | msg.RegionID = RegionInfo.RegionID.Guid; | 1742 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1901,6 +1958,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1901 | EventManager.TriggerPrimsLoaded(this); | 1958 | EventManager.TriggerPrimsLoaded(this); |
1902 | } | 1959 | } |
1903 | 1960 | ||
1961 | public bool SuportsRayCastFiltered() | ||
1962 | { | ||
1963 | if (PhysicsScene == null) | ||
1964 | return false; | ||
1965 | return PhysicsScene.SuportsRaycastWorldFiltered(); | ||
1966 | } | ||
1967 | |||
1968 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | ||
1969 | { | ||
1970 | if (PhysicsScene == null) | ||
1971 | return null; | ||
1972 | return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); | ||
1973 | } | ||
1904 | 1974 | ||
1905 | /// <summary> | 1975 | /// <summary> |
1906 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. | 1976 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. |
@@ -1917,14 +1987,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1917 | /// <returns></returns> | 1987 | /// <returns></returns> |
1918 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1988 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1919 | { | 1989 | { |
1990 | |||
1991 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1992 | Vector3 wpos = Vector3.Zero; | ||
1993 | // Check for water surface intersection from above | ||
1994 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1995 | { | ||
1996 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1997 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1998 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1999 | wpos.Z = wheight; | ||
2000 | } | ||
2001 | |||
1920 | Vector3 pos = Vector3.Zero; | 2002 | Vector3 pos = Vector3.Zero; |
1921 | if (RayEndIsIntersection == (byte)1) | 2003 | if (RayEndIsIntersection == (byte)1) |
1922 | { | 2004 | { |
1923 | pos = RayEnd; | 2005 | pos = RayEnd; |
1924 | return pos; | ||
1925 | } | 2006 | } |
1926 | 2007 | else if (RayTargetID != UUID.Zero) | |
1927 | if (RayTargetID != UUID.Zero) | ||
1928 | { | 2008 | { |
1929 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2009 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1930 | 2010 | ||
@@ -1946,7 +2026,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1946 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2026 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1947 | 2027 | ||
1948 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2028 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1949 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2029 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1950 | float ScaleOffset = 0.5f; | 2030 | float ScaleOffset = 0.5f; |
1951 | 2031 | ||
1952 | // If we hit something | 2032 | // If we hit something |
@@ -1969,13 +2049,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1969 | //pos.Z -= 0.25F; | 2049 | //pos.Z -= 0.25F; |
1970 | 2050 | ||
1971 | } | 2051 | } |
1972 | |||
1973 | return pos; | ||
1974 | } | 2052 | } |
1975 | else | 2053 | else |
1976 | { | 2054 | { |
1977 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2055 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1978 | |||
1979 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2056 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1980 | 2057 | ||
1981 | // Un-comment the following line to print the raytrace results to the console. | 2058 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1984,13 +2061,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1984 | if (ei.HitTF) | 2061 | if (ei.HitTF) |
1985 | { | 2062 | { |
1986 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2063 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1987 | } else | 2064 | } |
2065 | else | ||
1988 | { | 2066 | { |
1989 | // fall back to our stupid functionality | 2067 | // fall back to our stupid functionality |
1990 | pos = RayEnd; | 2068 | pos = RayEnd; |
1991 | } | 2069 | } |
1992 | |||
1993 | return pos; | ||
1994 | } | 2070 | } |
1995 | } | 2071 | } |
1996 | else | 2072 | else |
@@ -2001,8 +2077,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2001 | //increase height so its above the ground. | 2077 | //increase height so its above the ground. |
2002 | //should be getting the normal of the ground at the rez point and using that? | 2078 | //should be getting the normal of the ground at the rez point and using that? |
2003 | pos.Z += scale.Z / 2f; | 2079 | pos.Z += scale.Z / 2f; |
2004 | return pos; | 2080 | // return pos; |
2005 | } | 2081 | } |
2082 | |||
2083 | // check against posible water intercept | ||
2084 | if (wpos.Z > pos.Z) pos = wpos; | ||
2085 | return pos; | ||
2006 | } | 2086 | } |
2007 | 2087 | ||
2008 | 2088 | ||
@@ -2091,7 +2171,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2091 | public bool AddRestoredSceneObject( | 2171 | public bool AddRestoredSceneObject( |
2092 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2172 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
2093 | { | 2173 | { |
2094 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2174 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2175 | if (result) | ||
2176 | sceneObject.IsDeleted = false; | ||
2177 | return result; | ||
2095 | } | 2178 | } |
2096 | 2179 | ||
2097 | /// <summary> | 2180 | /// <summary> |
@@ -2183,6 +2266,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2183 | /// </summary> | 2266 | /// </summary> |
2184 | public void DeleteAllSceneObjects() | 2267 | public void DeleteAllSceneObjects() |
2185 | { | 2268 | { |
2269 | DeleteAllSceneObjects(false); | ||
2270 | } | ||
2271 | |||
2272 | /// <summary> | ||
2273 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2274 | /// </summary> | ||
2275 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2276 | { | ||
2277 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2186 | lock (Entities) | 2278 | lock (Entities) |
2187 | { | 2279 | { |
2188 | EntityBase[] entities = Entities.GetEntities(); | 2280 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2191,11 +2283,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2191 | if (e is SceneObjectGroup) | 2283 | if (e is SceneObjectGroup) |
2192 | { | 2284 | { |
2193 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2285 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2194 | if (!sog.IsAttachment) | 2286 | if (sog != null && !sog.IsAttachment) |
2195 | DeleteSceneObject((SceneObjectGroup)e, false); | 2287 | { |
2288 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2289 | { | ||
2290 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2291 | } | ||
2292 | else | ||
2293 | { | ||
2294 | toReturn.Add((SceneObjectGroup)e); | ||
2295 | } | ||
2296 | } | ||
2196 | } | 2297 | } |
2197 | } | 2298 | } |
2198 | } | 2299 | } |
2300 | if (toReturn.Count > 0) | ||
2301 | { | ||
2302 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2303 | } | ||
2199 | } | 2304 | } |
2200 | 2305 | ||
2201 | /// <summary> | 2306 | /// <summary> |
@@ -2247,6 +2352,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2247 | } | 2352 | } |
2248 | 2353 | ||
2249 | group.DeleteGroupFromScene(silent); | 2354 | group.DeleteGroupFromScene(silent); |
2355 | if (!silent) | ||
2356 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2250 | 2357 | ||
2251 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2358 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2252 | } | 2359 | } |
@@ -2537,7 +2644,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2537 | // If the user is banned, we won't let any of their objects | 2644 | // If the user is banned, we won't let any of their objects |
2538 | // enter. Period. | 2645 | // enter. Period. |
2539 | // | 2646 | // |
2540 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2647 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2541 | { | 2648 | { |
2542 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2649 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2543 | return false; | 2650 | return false; |
@@ -2545,6 +2652,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2545 | 2652 | ||
2546 | if (newPosition != Vector3.Zero) | 2653 | if (newPosition != Vector3.Zero) |
2547 | newObject.RootPart.GroupPosition = newPosition; | 2654 | newObject.RootPart.GroupPosition = newPosition; |
2655 | if (newObject.RootPart.KeyframeMotion != null) | ||
2656 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2548 | 2657 | ||
2549 | if (!AddSceneObject(newObject)) | 2658 | if (!AddSceneObject(newObject)) |
2550 | { | 2659 | { |
@@ -2589,6 +2698,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2589 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2698 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2590 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2699 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2591 | { | 2700 | { |
2701 | if (sceneObject.OwnerID == UUID.Zero) | ||
2702 | { | ||
2703 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2704 | return false; | ||
2705 | } | ||
2706 | |||
2707 | // If the user is banned, we won't let any of their objects | ||
2708 | // enter. Period. | ||
2709 | // | ||
2710 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2711 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2712 | { | ||
2713 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2714 | |||
2715 | return false; | ||
2716 | } | ||
2717 | |||
2592 | // Force allocation of new LocalId | 2718 | // Force allocation of new LocalId |
2593 | // | 2719 | // |
2594 | SceneObjectPart[] parts = sceneObject.Parts; | 2720 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2622,16 +2748,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2622 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2748 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2623 | 2749 | ||
2624 | if (AttachmentsModule != null) | 2750 | if (AttachmentsModule != null) |
2625 | AttachmentsModule.AttachObject(sp, grp, 0, false); | 2751 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); |
2626 | } | 2752 | } |
2627 | else | 2753 | else |
2628 | { | 2754 | { |
2755 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2629 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2756 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2630 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2757 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2631 | } | 2758 | } |
2759 | if (sceneObject.OwnerID == UUID.Zero) | ||
2760 | { | ||
2761 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2762 | return false; | ||
2763 | } | ||
2632 | } | 2764 | } |
2633 | else | 2765 | else |
2634 | { | 2766 | { |
2767 | if (sceneObject.OwnerID == UUID.Zero) | ||
2768 | { | ||
2769 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2770 | return false; | ||
2771 | } | ||
2635 | AddRestoredSceneObject(sceneObject, true, false); | 2772 | AddRestoredSceneObject(sceneObject, true, false); |
2636 | } | 2773 | } |
2637 | 2774 | ||
@@ -2648,6 +2785,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2648 | return 2; // StateSource.PrimCrossing | 2785 | return 2; // StateSource.PrimCrossing |
2649 | } | 2786 | } |
2650 | 2787 | ||
2788 | public int GetUserFlags(UUID user) | ||
2789 | { | ||
2790 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2791 | /* | ||
2792 | ScenePresence sp; | ||
2793 | if (TryGetScenePresence(user, out sp)) | ||
2794 | { | ||
2795 | return sp.UserFlags; | ||
2796 | } | ||
2797 | else | ||
2798 | { | ||
2799 | */ | ||
2800 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2801 | if (uac == null) | ||
2802 | return 0; | ||
2803 | return uac.UserFlags; | ||
2804 | //} | ||
2805 | } | ||
2651 | #endregion | 2806 | #endregion |
2652 | 2807 | ||
2653 | #region Add/Remove Avatar Methods | 2808 | #region Add/Remove Avatar Methods |
@@ -2661,7 +2816,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2661 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2816 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2662 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2817 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2663 | 2818 | ||
2664 | // CheckHeartbeat(); | 2819 | CheckHeartbeat(); |
2665 | 2820 | ||
2666 | ScenePresence sp = GetScenePresence(client.AgentId); | 2821 | ScenePresence sp = GetScenePresence(client.AgentId); |
2667 | 2822 | ||
@@ -2715,7 +2870,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2715 | 2870 | ||
2716 | EventManager.TriggerOnNewClient(client); | 2871 | EventManager.TriggerOnNewClient(client); |
2717 | if (vialogin) | 2872 | if (vialogin) |
2873 | { | ||
2718 | EventManager.TriggerOnClientLogin(client); | 2874 | EventManager.TriggerOnClientLogin(client); |
2875 | // Send initial parcel data | ||
2876 | Vector3 pos = sp.AbsolutePosition; | ||
2877 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2878 | land.SendLandUpdateToClient(client); | ||
2879 | } | ||
2719 | 2880 | ||
2720 | return sp; | 2881 | return sp; |
2721 | } | 2882 | } |
@@ -2804,19 +2965,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2804 | // and the scene presence and the client, if they exist | 2965 | // and the scene presence and the client, if they exist |
2805 | try | 2966 | try |
2806 | { | 2967 | { |
2807 | // We need to wait for the client to make UDP contact first. | 2968 | ScenePresence sp = GetScenePresence(agentID); |
2808 | // It's the UDP contact that creates the scene presence | 2969 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2809 | ScenePresence sp = WaitGetScenePresence(agentID); | 2970 | |
2810 | if (sp != null) | 2971 | if (sp != null) |
2811 | { | ||
2812 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2813 | |||
2814 | sp.ControllingClient.Close(); | 2972 | sp.ControllingClient.Close(); |
2815 | } | 2973 | |
2816 | else | ||
2817 | { | ||
2818 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2819 | } | ||
2820 | // BANG! SLASH! | 2974 | // BANG! SLASH! |
2821 | m_authenticateHandler.RemoveCircuit(agentID); | 2975 | m_authenticateHandler.RemoveCircuit(agentID); |
2822 | 2976 | ||
@@ -2861,6 +3015,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2861 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3015 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2862 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3016 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2863 | 3017 | ||
3018 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3019 | |||
2864 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3020 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2865 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3021 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2866 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3022 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2917,6 +3073,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2917 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3073 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2918 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3074 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2919 | client.OnCopyInventoryItem += CopyInventoryItem; | 3075 | client.OnCopyInventoryItem += CopyInventoryItem; |
3076 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2920 | client.OnMoveInventoryItem += MoveInventoryItem; | 3077 | client.OnMoveInventoryItem += MoveInventoryItem; |
2921 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3078 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2922 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3079 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2988,6 +3145,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2988 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3145 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2989 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3146 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2990 | 3147 | ||
3148 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3149 | |||
2991 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3150 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2992 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3151 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2993 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3152 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3090,7 +3249,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3090 | /// </summary> | 3249 | /// </summary> |
3091 | /// <param name="agentId">The avatar's Unique ID</param> | 3250 | /// <param name="agentId">The avatar's Unique ID</param> |
3092 | /// <param name="client">The IClientAPI for the client</param> | 3251 | /// <param name="client">The IClientAPI for the client</param> |
3093 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3252 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3094 | { | 3253 | { |
3095 | if (EntityTransferModule != null) | 3254 | if (EntityTransferModule != null) |
3096 | { | 3255 | { |
@@ -3101,6 +3260,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3101 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3260 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3102 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3261 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3103 | } | 3262 | } |
3263 | return false; | ||
3104 | } | 3264 | } |
3105 | 3265 | ||
3106 | /// <summary> | 3266 | /// <summary> |
@@ -3210,6 +3370,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3210 | /// <param name="flags"></param> | 3370 | /// <param name="flags"></param> |
3211 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3371 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3212 | { | 3372 | { |
3373 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3374 | ScenePresence presence; | ||
3375 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3376 | { | ||
3377 | if (presence.Appearance != null) | ||
3378 | { | ||
3379 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3380 | } | ||
3381 | } | ||
3382 | |||
3213 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3383 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3214 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3384 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3215 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3385 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3326,6 +3496,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3326 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3496 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3327 | 3497 | ||
3328 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3498 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3499 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3329 | } | 3500 | } |
3330 | catch (Exception e) | 3501 | catch (Exception e) |
3331 | { | 3502 | { |
@@ -3527,13 +3698,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3527 | sp = null; | 3698 | sp = null; |
3528 | } | 3699 | } |
3529 | 3700 | ||
3530 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3531 | 3701 | ||
3532 | //On login test land permisions | 3702 | //On login test land permisions |
3533 | if (vialogin) | 3703 | if (vialogin) |
3534 | { | 3704 | { |
3535 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3705 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3706 | if (cache != null) | ||
3707 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3708 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3536 | { | 3709 | { |
3710 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3537 | return false; | 3711 | return false; |
3538 | } | 3712 | } |
3539 | } | 3713 | } |
@@ -3556,9 +3730,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3556 | 3730 | ||
3557 | try | 3731 | try |
3558 | { | 3732 | { |
3559 | if (!AuthorizeUser(agent, out reason)) | 3733 | // Always check estate if this is a login. Always |
3560 | return false; | 3734 | // check if banned regions are to be blacked out. |
3561 | } catch (Exception e) | 3735 | if (vialogin || (!m_seeIntoBannedRegion)) |
3736 | { | ||
3737 | if (!AuthorizeUser(agent, out reason)) | ||
3738 | return false; | ||
3739 | } | ||
3740 | } | ||
3741 | catch (Exception e) | ||
3562 | { | 3742 | { |
3563 | m_log.ErrorFormat( | 3743 | m_log.ErrorFormat( |
3564 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3744 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3689,6 +3869,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3689 | } | 3869 | } |
3690 | 3870 | ||
3691 | // Honor parcel landing type and position. | 3871 | // Honor parcel landing type and position. |
3872 | /* | ||
3873 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3692 | if (land != null) | 3874 | if (land != null) |
3693 | { | 3875 | { |
3694 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3876 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3696,25 +3878,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3696 | agent.startpos = land.LandData.UserLocation; | 3878 | agent.startpos = land.LandData.UserLocation; |
3697 | } | 3879 | } |
3698 | } | 3880 | } |
3881 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3699 | } | 3882 | } |
3700 | 3883 | ||
3701 | return true; | 3884 | return true; |
3702 | } | 3885 | } |
3703 | 3886 | ||
3704 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3887 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3705 | { | 3888 | { |
3706 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3889 | reason = String.Empty; |
3707 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3890 | if (Permissions.IsGod(agentID)) |
3891 | return true; | ||
3892 | |||
3893 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3894 | if (land == null) | ||
3895 | return false; | ||
3896 | |||
3897 | bool banned = land.IsBannedFromLand(agentID); | ||
3898 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3708 | 3899 | ||
3709 | if (banned || restricted) | 3900 | if (banned || restricted) |
3710 | { | 3901 | { |
3711 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3902 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3712 | if (nearestParcel != null) | 3903 | if (nearestParcel != null) |
3713 | { | 3904 | { |
3714 | //Move agent to nearest allowed | 3905 | //Move agent to nearest allowed |
3715 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3906 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3716 | agent.startpos.X = newPosition.X; | 3907 | posX = newPosition.X; |
3717 | agent.startpos.Y = newPosition.Y; | 3908 | posY = newPosition.Y; |
3718 | } | 3909 | } |
3719 | else | 3910 | else |
3720 | { | 3911 | { |
@@ -3776,7 +3967,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3776 | 3967 | ||
3777 | if (!m_strictAccessControl) return true; | 3968 | if (!m_strictAccessControl) return true; |
3778 | if (Permissions.IsGod(agent.AgentID)) return true; | 3969 | if (Permissions.IsGod(agent.AgentID)) return true; |
3779 | 3970 | ||
3780 | if (AuthorizationService != null) | 3971 | if (AuthorizationService != null) |
3781 | { | 3972 | { |
3782 | if (!AuthorizationService.IsAuthorizedForRegion( | 3973 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3791,7 +3982,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3791 | 3982 | ||
3792 | if (RegionInfo.EstateSettings != null) | 3983 | if (RegionInfo.EstateSettings != null) |
3793 | { | 3984 | { |
3794 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 3985 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3795 | { | 3986 | { |
3796 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3987 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3797 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3988 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3981,6 +4172,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3981 | 4172 | ||
3982 | // XPTO: if this agent is not allowed here as root, always return false | 4173 | // XPTO: if this agent is not allowed here as root, always return false |
3983 | 4174 | ||
4175 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4176 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4177 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4178 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4179 | { | ||
4180 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4181 | return false; | ||
4182 | } | ||
4183 | |||
3984 | // TODO: This check should probably be in QueryAccess(). | 4184 | // TODO: This check should probably be in QueryAccess(). |
3985 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4185 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3986 | if (nearestParcel == null) | 4186 | if (nearestParcel == null) |
@@ -4074,12 +4274,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4074 | return false; | 4274 | return false; |
4075 | } | 4275 | } |
4076 | 4276 | ||
4277 | public bool IncomingCloseAgent(UUID agentID) | ||
4278 | { | ||
4279 | return IncomingCloseAgent(agentID, false); | ||
4280 | } | ||
4281 | |||
4282 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4283 | { | ||
4284 | return IncomingCloseAgent(agentID, true); | ||
4285 | } | ||
4286 | |||
4077 | /// <summary> | 4287 | /// <summary> |
4078 | /// Tell a single agent to disconnect from the region. | 4288 | /// Tell a single agent to disconnect from the region. |
4079 | /// </summary> | 4289 | /// </summary> |
4080 | /// <param name="regionHandle"></param> | ||
4081 | /// <param name="agentID"></param> | 4290 | /// <param name="agentID"></param> |
4082 | public bool IncomingCloseAgent(UUID agentID) | 4291 | /// <param name="childOnly"></param> |
4292 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
4083 | { | 4293 | { |
4084 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4294 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
4085 | 4295 | ||
@@ -4700,35 +4910,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4700 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 4910 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4701 | } | 4911 | } |
4702 | 4912 | ||
4703 | public int GetHealth() | 4913 | public int GetHealth(out int flags, out string message) |
4704 | { | 4914 | { |
4705 | // Returns: | 4915 | // Returns: |
4706 | // 1 = sim is up and accepting http requests. The heartbeat has | 4916 | // 1 = sim is up and accepting http requests. The heartbeat has |
4707 | // stopped and the sim is probably locked up, but a remote | 4917 | // stopped and the sim is probably locked up, but a remote |
4708 | // admin restart may succeed | 4918 | // admin restart may succeed |
4709 | // | 4919 | // |
4710 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4920 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4711 | // usable for people within and logins _may_ work | 4921 | // usable for people within |
4922 | // | ||
4923 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4924 | // unstable and will not accept new logins | ||
4925 | // | ||
4926 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4927 | // likely usable | ||
4712 | // | 4928 | // |
4713 | // 3 = We have seen a new user enter within the past 4 minutes | 4929 | // 5 = We have seen a new user enter within the past 4 minutes |
4714 | // which can be seen as positive confirmation of sim health | 4930 | // which can be seen as positive confirmation of sim health |
4715 | // | 4931 | // |
4932 | |||
4933 | flags = 0; | ||
4934 | message = String.Empty; | ||
4935 | |||
4936 | CheckHeartbeat(); | ||
4937 | |||
4938 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4939 | { | ||
4940 | // We're still starting | ||
4941 | // 0 means "in startup", it can't happen another way, since | ||
4942 | // to get here, we must be able to accept http connections | ||
4943 | return 0; | ||
4944 | } | ||
4945 | |||
4716 | int health=1; // Start at 1, means we're up | 4946 | int health=1; // Start at 1, means we're up |
4717 | 4947 | ||
4718 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4948 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4719 | health += 1; | 4949 | { |
4950 | health+=1; | ||
4951 | flags |= 1; | ||
4952 | } | ||
4953 | |||
4954 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4955 | { | ||
4956 | health+=1; | ||
4957 | flags |= 2; | ||
4958 | } | ||
4959 | |||
4960 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4961 | { | ||
4962 | health+=1; | ||
4963 | flags |= 4; | ||
4964 | } | ||
4720 | else | 4965 | else |
4966 | { | ||
4967 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4968 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4969 | proc.EnableRaisingEvents=false; | ||
4970 | proc.StartInfo.FileName = "/bin/kill"; | ||
4971 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4972 | proc.Start(); | ||
4973 | proc.WaitForExit(); | ||
4974 | Thread.Sleep(1000); | ||
4975 | Environment.Exit(1); | ||
4976 | } | ||
4977 | |||
4978 | if (flags != 7) | ||
4721 | return health; | 4979 | return health; |
4722 | 4980 | ||
4723 | // A login in the last 4 mins? We can't be doing too badly | 4981 | // A login in the last 4 mins? We can't be doing too badly |
4724 | // | 4982 | // |
4725 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4983 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4726 | health++; | 4984 | health++; |
4727 | else | 4985 | else |
4728 | return health; | 4986 | return health; |
4729 | 4987 | ||
4730 | // CheckHeartbeat(); | ||
4731 | |||
4732 | return health; | 4988 | return health; |
4733 | } | 4989 | } |
4734 | 4990 | ||
@@ -4816,7 +5072,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4816 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5072 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4817 | if (wasUsingPhysics) | 5073 | if (wasUsingPhysics) |
4818 | { | 5074 | { |
4819 | 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 | 5075 | 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 |
4820 | } | 5076 | } |
4821 | } | 5077 | } |
4822 | 5078 | ||
@@ -4915,14 +5171,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4915 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5171 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4916 | } | 5172 | } |
4917 | 5173 | ||
4918 | // private void CheckHeartbeat() | 5174 | private void CheckHeartbeat() |
4919 | // { | 5175 | { |
4920 | // if (m_firstHeartbeat) | 5176 | if (m_firstHeartbeat) |
4921 | // return; | 5177 | return; |
4922 | // | 5178 | |
4923 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5179 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4924 | // StartTimer(); | 5180 | Start(); |
4925 | // } | 5181 | } |
4926 | 5182 | ||
4927 | public override ISceneObject DeserializeObject(string representation) | 5183 | public override ISceneObject DeserializeObject(string representation) |
4928 | { | 5184 | { |
@@ -4934,9 +5190,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4934 | get { return m_allowScriptCrossings; } | 5190 | get { return m_allowScriptCrossings; } |
4935 | } | 5191 | } |
4936 | 5192 | ||
4937 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5193 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4938 | { | 5194 | { |
4939 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5195 | return GetNearestAllowedPosition(avatar, null); |
5196 | } | ||
5197 | |||
5198 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
5199 | { | ||
5200 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
4940 | 5201 | ||
4941 | if (nearestParcel != null) | 5202 | if (nearestParcel != null) |
4942 | { | 5203 | { |
@@ -4945,10 +5206,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4945 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5206 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4946 | if (nearestPoint != null) | 5207 | if (nearestPoint != null) |
4947 | { | 5208 | { |
4948 | // m_log.DebugFormat( | 5209 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4949 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4950 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4951 | |||
4952 | return nearestPoint.Value; | 5210 | return nearestPoint.Value; |
4953 | } | 5211 | } |
4954 | 5212 | ||
@@ -4958,17 +5216,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4958 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5216 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4959 | if (nearestPoint != null) | 5217 | if (nearestPoint != null) |
4960 | { | 5218 | { |
4961 | // m_log.DebugFormat( | 5219 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4962 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4963 | |||
4964 | return nearestPoint.Value; | 5220 | return nearestPoint.Value; |
4965 | } | 5221 | } |
4966 | 5222 | ||
4967 | //Ultimate backup if we have no idea where they are | 5223 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4968 | // m_log.DebugFormat( | 5224 | if (dest != excludeParcel) |
4969 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5225 | { |
5226 | // Ultimate backup if we have no idea where they are and | ||
5227 | // the last allowed position was in another parcel | ||
5228 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5229 | return avatar.lastKnownAllowedPosition; | ||
5230 | } | ||
4970 | 5231 | ||
4971 | return avatar.lastKnownAllowedPosition; | 5232 | // else fall through to region edge |
4972 | } | 5233 | } |
4973 | 5234 | ||
4974 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5235 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -5002,13 +5263,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5002 | 5263 | ||
5003 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5264 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
5004 | { | 5265 | { |
5266 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5267 | } | ||
5268 | |||
5269 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5270 | { | ||
5005 | List<ILandObject> all = AllParcels(); | 5271 | List<ILandObject> all = AllParcels(); |
5006 | float minParcelDistance = float.MaxValue; | 5272 | float minParcelDistance = float.MaxValue; |
5007 | ILandObject nearestParcel = null; | 5273 | ILandObject nearestParcel = null; |
5008 | 5274 | ||
5009 | foreach (var parcel in all) | 5275 | foreach (var parcel in all) |
5010 | { | 5276 | { |
5011 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5277 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
5012 | { | 5278 | { |
5013 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5279 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
5014 | if (parcelDistance < minParcelDistance) | 5280 | if (parcelDistance < minParcelDistance) |
@@ -5250,7 +5516,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5250 | mapModule.GenerateMaptile(); | 5516 | mapModule.GenerateMaptile(); |
5251 | } | 5517 | } |
5252 | 5518 | ||
5253 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5519 | // public void CleanDroppedAttachments() |
5520 | // { | ||
5521 | // List<SceneObjectGroup> objectsToDelete = | ||
5522 | // new List<SceneObjectGroup>(); | ||
5523 | // | ||
5524 | // lock (m_cleaningAttachments) | ||
5525 | // { | ||
5526 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5527 | // { | ||
5528 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5529 | // { | ||
5530 | // UUID agentID = grp.OwnerID; | ||
5531 | // if (agentID == UUID.Zero) | ||
5532 | // { | ||
5533 | // objectsToDelete.Add(grp); | ||
5534 | // return; | ||
5535 | // } | ||
5536 | // | ||
5537 | // ScenePresence sp = GetScenePresence(agentID); | ||
5538 | // if (sp == null) | ||
5539 | // { | ||
5540 | // objectsToDelete.Add(grp); | ||
5541 | // return; | ||
5542 | // } | ||
5543 | // } | ||
5544 | // }); | ||
5545 | // } | ||
5546 | // | ||
5547 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5548 | // { | ||
5549 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5550 | // DeleteSceneObject(grp, true); | ||
5551 | // } | ||
5552 | // } | ||
5553 | |||
5554 | public void ThreadAlive(int threadCode) | ||
5555 | { | ||
5556 | switch(threadCode) | ||
5557 | { | ||
5558 | case 1: // Incoming | ||
5559 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5560 | break; | ||
5561 | case 2: // Incoming | ||
5562 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5563 | break; | ||
5564 | } | ||
5565 | } | ||
5566 | |||
5567 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5254 | { | 5568 | { |
5255 | RegenerateMaptile(); | 5569 | RegenerateMaptile(); |
5256 | 5570 | ||
@@ -5278,6 +5592,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5278 | /// <returns></returns> | 5592 | /// <returns></returns> |
5279 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5593 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5280 | { | 5594 | { |
5595 | reason = "You are banned from the region"; | ||
5596 | |||
5281 | if (EntityTransferModule.IsInTransit(agentID)) | 5597 | if (EntityTransferModule.IsInTransit(agentID)) |
5282 | { | 5598 | { |
5283 | reason = "Agent is still in transit from this region"; | 5599 | reason = "Agent is still in transit from this region"; |
@@ -5289,6 +5605,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5289 | return false; | 5605 | return false; |
5290 | } | 5606 | } |
5291 | 5607 | ||
5608 | if (Permissions.IsGod(agentID)) | ||
5609 | { | ||
5610 | reason = String.Empty; | ||
5611 | return true; | ||
5612 | } | ||
5613 | |||
5292 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5614 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5293 | // However, the long term fix is to make sure root agent count is always accurate. | 5615 | // However, the long term fix is to make sure root agent count is always accurate. |
5294 | m_sceneGraph.RecalculateStats(); | 5616 | m_sceneGraph.RecalculateStats(); |
@@ -5309,6 +5631,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5309 | } | 5631 | } |
5310 | } | 5632 | } |
5311 | 5633 | ||
5634 | ScenePresence presence = GetScenePresence(agentID); | ||
5635 | IClientAPI client = null; | ||
5636 | AgentCircuitData aCircuit = null; | ||
5637 | |||
5638 | if (presence != null) | ||
5639 | { | ||
5640 | client = presence.ControllingClient; | ||
5641 | if (client != null) | ||
5642 | aCircuit = client.RequestClientInfo(); | ||
5643 | } | ||
5644 | |||
5645 | // We may be called before there is a presence or a client. | ||
5646 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5647 | if (client == null) | ||
5648 | { | ||
5649 | aCircuit = new AgentCircuitData(); | ||
5650 | aCircuit.AgentID = agentID; | ||
5651 | aCircuit.firstname = String.Empty; | ||
5652 | aCircuit.lastname = String.Empty; | ||
5653 | } | ||
5654 | |||
5655 | try | ||
5656 | { | ||
5657 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5658 | { | ||
5659 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5660 | return false; | ||
5661 | } | ||
5662 | } | ||
5663 | catch (Exception e) | ||
5664 | { | ||
5665 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5666 | return false; | ||
5667 | } | ||
5668 | |||
5312 | if (position == Vector3.Zero) // Teleport | 5669 | if (position == Vector3.Zero) // Teleport |
5313 | { | 5670 | { |
5314 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5671 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5337,13 +5694,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5337 | } | 5694 | } |
5338 | } | 5695 | } |
5339 | } | 5696 | } |
5697 | |||
5698 | float posX = 128.0f; | ||
5699 | float posY = 128.0f; | ||
5700 | |||
5701 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5702 | { | ||
5703 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5704 | return false; | ||
5705 | } | ||
5706 | } | ||
5707 | else // Walking | ||
5708 | { | ||
5709 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5710 | if (land == null) | ||
5711 | return false; | ||
5712 | |||
5713 | bool banned = land.IsBannedFromLand(agentID); | ||
5714 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5715 | |||
5716 | if (banned || restricted) | ||
5717 | return false; | ||
5340 | } | 5718 | } |
5341 | 5719 | ||
5342 | reason = String.Empty; | 5720 | reason = String.Empty; |
5343 | return true; | 5721 | return true; |
5344 | } | 5722 | } |
5345 | 5723 | ||
5346 | /// <summary> | 5724 | public void StartTimerWatchdog() |
5725 | { | ||
5726 | m_timerWatchdog.Interval = 1000; | ||
5727 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5728 | m_timerWatchdog.AutoReset = true; | ||
5729 | m_timerWatchdog.Start(); | ||
5730 | } | ||
5731 | |||
5732 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5733 | { | ||
5734 | CheckHeartbeat(); | ||
5735 | } | ||
5736 | |||
5347 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5737 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5348 | /// autopilot that moves an avatar to a sit target!. | 5738 | /// autopilot that moves an avatar to a sit target!. |
5349 | /// </summary> | 5739 | /// </summary> |
@@ -5421,5 +5811,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
5421 | m_SpawnPoint = 1; | 5811 | m_SpawnPoint = 1; |
5422 | return m_SpawnPoint - 1; | 5812 | return m_SpawnPoint - 1; |
5423 | } | 5813 | } |
5814 | |||
5815 | private void HandleGcCollect(string module, string[] args) | ||
5816 | { | ||
5817 | GC.Collect(); | ||
5818 | } | ||
5424 | } | 5819 | } |
5425 | } | 5820 | } |