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 51a6820..56c58b7 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."); |
@@ -3324,6 +3494,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3324 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3494 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3325 | 3495 | ||
3326 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3496 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3497 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3327 | } | 3498 | } |
3328 | catch (Exception e) | 3499 | catch (Exception e) |
3329 | { | 3500 | { |
@@ -3525,13 +3696,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3525 | sp = null; | 3696 | sp = null; |
3526 | } | 3697 | } |
3527 | 3698 | ||
3528 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3529 | 3699 | ||
3530 | //On login test land permisions | 3700 | //On login test land permisions |
3531 | if (vialogin) | 3701 | if (vialogin) |
3532 | { | 3702 | { |
3533 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3703 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3704 | if (cache != null) | ||
3705 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3706 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3534 | { | 3707 | { |
3708 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3535 | return false; | 3709 | return false; |
3536 | } | 3710 | } |
3537 | } | 3711 | } |
@@ -3554,9 +3728,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3554 | 3728 | ||
3555 | try | 3729 | try |
3556 | { | 3730 | { |
3557 | if (!AuthorizeUser(agent, out reason)) | 3731 | // Always check estate if this is a login. Always |
3558 | return false; | 3732 | // check if banned regions are to be blacked out. |
3559 | } catch (Exception e) | 3733 | if (vialogin || (!m_seeIntoBannedRegion)) |
3734 | { | ||
3735 | if (!AuthorizeUser(agent, out reason)) | ||
3736 | return false; | ||
3737 | } | ||
3738 | } | ||
3739 | catch (Exception e) | ||
3560 | { | 3740 | { |
3561 | m_log.ErrorFormat( | 3741 | m_log.ErrorFormat( |
3562 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3742 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3687,6 +3867,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3687 | } | 3867 | } |
3688 | 3868 | ||
3689 | // Honor parcel landing type and position. | 3869 | // Honor parcel landing type and position. |
3870 | /* | ||
3871 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3690 | if (land != null) | 3872 | if (land != null) |
3691 | { | 3873 | { |
3692 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3874 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3694,25 +3876,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3694 | agent.startpos = land.LandData.UserLocation; | 3876 | agent.startpos = land.LandData.UserLocation; |
3695 | } | 3877 | } |
3696 | } | 3878 | } |
3879 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3697 | } | 3880 | } |
3698 | 3881 | ||
3699 | return true; | 3882 | return true; |
3700 | } | 3883 | } |
3701 | 3884 | ||
3702 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3885 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3703 | { | 3886 | { |
3704 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3887 | reason = String.Empty; |
3705 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3888 | if (Permissions.IsGod(agentID)) |
3889 | return true; | ||
3890 | |||
3891 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3892 | if (land == null) | ||
3893 | return false; | ||
3894 | |||
3895 | bool banned = land.IsBannedFromLand(agentID); | ||
3896 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3706 | 3897 | ||
3707 | if (banned || restricted) | 3898 | if (banned || restricted) |
3708 | { | 3899 | { |
3709 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3900 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3710 | if (nearestParcel != null) | 3901 | if (nearestParcel != null) |
3711 | { | 3902 | { |
3712 | //Move agent to nearest allowed | 3903 | //Move agent to nearest allowed |
3713 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3904 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3714 | agent.startpos.X = newPosition.X; | 3905 | posX = newPosition.X; |
3715 | agent.startpos.Y = newPosition.Y; | 3906 | posY = newPosition.Y; |
3716 | } | 3907 | } |
3717 | else | 3908 | else |
3718 | { | 3909 | { |
@@ -3774,7 +3965,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3774 | 3965 | ||
3775 | if (!m_strictAccessControl) return true; | 3966 | if (!m_strictAccessControl) return true; |
3776 | if (Permissions.IsGod(agent.AgentID)) return true; | 3967 | if (Permissions.IsGod(agent.AgentID)) return true; |
3777 | 3968 | ||
3778 | if (AuthorizationService != null) | 3969 | if (AuthorizationService != null) |
3779 | { | 3970 | { |
3780 | if (!AuthorizationService.IsAuthorizedForRegion( | 3971 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3789,7 +3980,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3789 | 3980 | ||
3790 | if (RegionInfo.EstateSettings != null) | 3981 | if (RegionInfo.EstateSettings != null) |
3791 | { | 3982 | { |
3792 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 3983 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3793 | { | 3984 | { |
3794 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3985 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3795 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3986 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3979,6 +4170,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3979 | 4170 | ||
3980 | // XPTO: if this agent is not allowed here as root, always return false | 4171 | // XPTO: if this agent is not allowed here as root, always return false |
3981 | 4172 | ||
4173 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4174 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4175 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4176 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4177 | { | ||
4178 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4179 | return false; | ||
4180 | } | ||
4181 | |||
3982 | // TODO: This check should probably be in QueryAccess(). | 4182 | // TODO: This check should probably be in QueryAccess(). |
3983 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4183 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3984 | if (nearestParcel == null) | 4184 | if (nearestParcel == null) |
@@ -4072,12 +4272,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4072 | return false; | 4272 | return false; |
4073 | } | 4273 | } |
4074 | 4274 | ||
4275 | public bool IncomingCloseAgent(UUID agentID) | ||
4276 | { | ||
4277 | return IncomingCloseAgent(agentID, false); | ||
4278 | } | ||
4279 | |||
4280 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4281 | { | ||
4282 | return IncomingCloseAgent(agentID, true); | ||
4283 | } | ||
4284 | |||
4075 | /// <summary> | 4285 | /// <summary> |
4076 | /// Tell a single agent to disconnect from the region. | 4286 | /// Tell a single agent to disconnect from the region. |
4077 | /// </summary> | 4287 | /// </summary> |
4078 | /// <param name="regionHandle"></param> | ||
4079 | /// <param name="agentID"></param> | 4288 | /// <param name="agentID"></param> |
4080 | public bool IncomingCloseAgent(UUID agentID) | 4289 | /// <param name="childOnly"></param> |
4290 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
4081 | { | 4291 | { |
4082 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4292 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
4083 | 4293 | ||
@@ -4698,35 +4908,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4698 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 4908 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4699 | } | 4909 | } |
4700 | 4910 | ||
4701 | public int GetHealth() | 4911 | public int GetHealth(out int flags, out string message) |
4702 | { | 4912 | { |
4703 | // Returns: | 4913 | // Returns: |
4704 | // 1 = sim is up and accepting http requests. The heartbeat has | 4914 | // 1 = sim is up and accepting http requests. The heartbeat has |
4705 | // stopped and the sim is probably locked up, but a remote | 4915 | // stopped and the sim is probably locked up, but a remote |
4706 | // admin restart may succeed | 4916 | // admin restart may succeed |
4707 | // | 4917 | // |
4708 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4918 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4709 | // usable for people within and logins _may_ work | 4919 | // usable for people within |
4920 | // | ||
4921 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4922 | // unstable and will not accept new logins | ||
4923 | // | ||
4924 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4925 | // likely usable | ||
4710 | // | 4926 | // |
4711 | // 3 = We have seen a new user enter within the past 4 minutes | 4927 | // 5 = We have seen a new user enter within the past 4 minutes |
4712 | // which can be seen as positive confirmation of sim health | 4928 | // which can be seen as positive confirmation of sim health |
4713 | // | 4929 | // |
4930 | |||
4931 | flags = 0; | ||
4932 | message = String.Empty; | ||
4933 | |||
4934 | CheckHeartbeat(); | ||
4935 | |||
4936 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4937 | { | ||
4938 | // We're still starting | ||
4939 | // 0 means "in startup", it can't happen another way, since | ||
4940 | // to get here, we must be able to accept http connections | ||
4941 | return 0; | ||
4942 | } | ||
4943 | |||
4714 | int health=1; // Start at 1, means we're up | 4944 | int health=1; // Start at 1, means we're up |
4715 | 4945 | ||
4716 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4946 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4717 | health += 1; | 4947 | { |
4948 | health+=1; | ||
4949 | flags |= 1; | ||
4950 | } | ||
4951 | |||
4952 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4953 | { | ||
4954 | health+=1; | ||
4955 | flags |= 2; | ||
4956 | } | ||
4957 | |||
4958 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4959 | { | ||
4960 | health+=1; | ||
4961 | flags |= 4; | ||
4962 | } | ||
4718 | else | 4963 | else |
4964 | { | ||
4965 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4966 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4967 | proc.EnableRaisingEvents=false; | ||
4968 | proc.StartInfo.FileName = "/bin/kill"; | ||
4969 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4970 | proc.Start(); | ||
4971 | proc.WaitForExit(); | ||
4972 | Thread.Sleep(1000); | ||
4973 | Environment.Exit(1); | ||
4974 | } | ||
4975 | |||
4976 | if (flags != 7) | ||
4719 | return health; | 4977 | return health; |
4720 | 4978 | ||
4721 | // A login in the last 4 mins? We can't be doing too badly | 4979 | // A login in the last 4 mins? We can't be doing too badly |
4722 | // | 4980 | // |
4723 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4981 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4724 | health++; | 4982 | health++; |
4725 | else | 4983 | else |
4726 | return health; | 4984 | return health; |
4727 | 4985 | ||
4728 | // CheckHeartbeat(); | ||
4729 | |||
4730 | return health; | 4986 | return health; |
4731 | } | 4987 | } |
4732 | 4988 | ||
@@ -4814,7 +5070,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4814 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5070 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4815 | if (wasUsingPhysics) | 5071 | if (wasUsingPhysics) |
4816 | { | 5072 | { |
4817 | 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 | 5073 | 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 |
4818 | } | 5074 | } |
4819 | } | 5075 | } |
4820 | 5076 | ||
@@ -4913,14 +5169,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4913 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5169 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4914 | } | 5170 | } |
4915 | 5171 | ||
4916 | // private void CheckHeartbeat() | 5172 | private void CheckHeartbeat() |
4917 | // { | 5173 | { |
4918 | // if (m_firstHeartbeat) | 5174 | if (m_firstHeartbeat) |
4919 | // return; | 5175 | return; |
4920 | // | 5176 | |
4921 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5177 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4922 | // StartTimer(); | 5178 | Start(); |
4923 | // } | 5179 | } |
4924 | 5180 | ||
4925 | public override ISceneObject DeserializeObject(string representation) | 5181 | public override ISceneObject DeserializeObject(string representation) |
4926 | { | 5182 | { |
@@ -4932,9 +5188,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4932 | get { return m_allowScriptCrossings; } | 5188 | get { return m_allowScriptCrossings; } |
4933 | } | 5189 | } |
4934 | 5190 | ||
4935 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5191 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4936 | { | 5192 | { |
4937 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5193 | return GetNearestAllowedPosition(avatar, null); |
5194 | } | ||
5195 | |||
5196 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
5197 | { | ||
5198 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
4938 | 5199 | ||
4939 | if (nearestParcel != null) | 5200 | if (nearestParcel != null) |
4940 | { | 5201 | { |
@@ -4943,10 +5204,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4943 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5204 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4944 | if (nearestPoint != null) | 5205 | if (nearestPoint != null) |
4945 | { | 5206 | { |
4946 | // m_log.DebugFormat( | 5207 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4947 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4948 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4949 | |||
4950 | return nearestPoint.Value; | 5208 | return nearestPoint.Value; |
4951 | } | 5209 | } |
4952 | 5210 | ||
@@ -4956,17 +5214,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4956 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5214 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4957 | if (nearestPoint != null) | 5215 | if (nearestPoint != null) |
4958 | { | 5216 | { |
4959 | // m_log.DebugFormat( | 5217 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4960 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4961 | |||
4962 | return nearestPoint.Value; | 5218 | return nearestPoint.Value; |
4963 | } | 5219 | } |
4964 | 5220 | ||
4965 | //Ultimate backup if we have no idea where they are | 5221 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4966 | // m_log.DebugFormat( | 5222 | if (dest != excludeParcel) |
4967 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5223 | { |
5224 | // Ultimate backup if we have no idea where they are and | ||
5225 | // the last allowed position was in another parcel | ||
5226 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5227 | return avatar.lastKnownAllowedPosition; | ||
5228 | } | ||
4968 | 5229 | ||
4969 | return avatar.lastKnownAllowedPosition; | 5230 | // else fall through to region edge |
4970 | } | 5231 | } |
4971 | 5232 | ||
4972 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5233 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -5000,13 +5261,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5000 | 5261 | ||
5001 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5262 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
5002 | { | 5263 | { |
5264 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5265 | } | ||
5266 | |||
5267 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5268 | { | ||
5003 | List<ILandObject> all = AllParcels(); | 5269 | List<ILandObject> all = AllParcels(); |
5004 | float minParcelDistance = float.MaxValue; | 5270 | float minParcelDistance = float.MaxValue; |
5005 | ILandObject nearestParcel = null; | 5271 | ILandObject nearestParcel = null; |
5006 | 5272 | ||
5007 | foreach (var parcel in all) | 5273 | foreach (var parcel in all) |
5008 | { | 5274 | { |
5009 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5275 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
5010 | { | 5276 | { |
5011 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5277 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
5012 | if (parcelDistance < minParcelDistance) | 5278 | if (parcelDistance < minParcelDistance) |
@@ -5248,7 +5514,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5248 | mapModule.GenerateMaptile(); | 5514 | mapModule.GenerateMaptile(); |
5249 | } | 5515 | } |
5250 | 5516 | ||
5251 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5517 | // public void CleanDroppedAttachments() |
5518 | // { | ||
5519 | // List<SceneObjectGroup> objectsToDelete = | ||
5520 | // new List<SceneObjectGroup>(); | ||
5521 | // | ||
5522 | // lock (m_cleaningAttachments) | ||
5523 | // { | ||
5524 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5525 | // { | ||
5526 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5527 | // { | ||
5528 | // UUID agentID = grp.OwnerID; | ||
5529 | // if (agentID == UUID.Zero) | ||
5530 | // { | ||
5531 | // objectsToDelete.Add(grp); | ||
5532 | // return; | ||
5533 | // } | ||
5534 | // | ||
5535 | // ScenePresence sp = GetScenePresence(agentID); | ||
5536 | // if (sp == null) | ||
5537 | // { | ||
5538 | // objectsToDelete.Add(grp); | ||
5539 | // return; | ||
5540 | // } | ||
5541 | // } | ||
5542 | // }); | ||
5543 | // } | ||
5544 | // | ||
5545 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5546 | // { | ||
5547 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5548 | // DeleteSceneObject(grp, true); | ||
5549 | // } | ||
5550 | // } | ||
5551 | |||
5552 | public void ThreadAlive(int threadCode) | ||
5553 | { | ||
5554 | switch(threadCode) | ||
5555 | { | ||
5556 | case 1: // Incoming | ||
5557 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5558 | break; | ||
5559 | case 2: // Incoming | ||
5560 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5561 | break; | ||
5562 | } | ||
5563 | } | ||
5564 | |||
5565 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5252 | { | 5566 | { |
5253 | RegenerateMaptile(); | 5567 | RegenerateMaptile(); |
5254 | 5568 | ||
@@ -5276,6 +5590,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5276 | /// <returns></returns> | 5590 | /// <returns></returns> |
5277 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5591 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5278 | { | 5592 | { |
5593 | reason = "You are banned from the region"; | ||
5594 | |||
5279 | if (EntityTransferModule.IsInTransit(agentID)) | 5595 | if (EntityTransferModule.IsInTransit(agentID)) |
5280 | { | 5596 | { |
5281 | reason = "Agent is still in transit from this region"; | 5597 | reason = "Agent is still in transit from this region"; |
@@ -5287,6 +5603,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5287 | return false; | 5603 | return false; |
5288 | } | 5604 | } |
5289 | 5605 | ||
5606 | if (Permissions.IsGod(agentID)) | ||
5607 | { | ||
5608 | reason = String.Empty; | ||
5609 | return true; | ||
5610 | } | ||
5611 | |||
5290 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5612 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5291 | // However, the long term fix is to make sure root agent count is always accurate. | 5613 | // However, the long term fix is to make sure root agent count is always accurate. |
5292 | m_sceneGraph.RecalculateStats(); | 5614 | m_sceneGraph.RecalculateStats(); |
@@ -5307,6 +5629,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5307 | } | 5629 | } |
5308 | } | 5630 | } |
5309 | 5631 | ||
5632 | ScenePresence presence = GetScenePresence(agentID); | ||
5633 | IClientAPI client = null; | ||
5634 | AgentCircuitData aCircuit = null; | ||
5635 | |||
5636 | if (presence != null) | ||
5637 | { | ||
5638 | client = presence.ControllingClient; | ||
5639 | if (client != null) | ||
5640 | aCircuit = client.RequestClientInfo(); | ||
5641 | } | ||
5642 | |||
5643 | // We may be called before there is a presence or a client. | ||
5644 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5645 | if (client == null) | ||
5646 | { | ||
5647 | aCircuit = new AgentCircuitData(); | ||
5648 | aCircuit.AgentID = agentID; | ||
5649 | aCircuit.firstname = String.Empty; | ||
5650 | aCircuit.lastname = String.Empty; | ||
5651 | } | ||
5652 | |||
5653 | try | ||
5654 | { | ||
5655 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5656 | { | ||
5657 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5658 | return false; | ||
5659 | } | ||
5660 | } | ||
5661 | catch (Exception e) | ||
5662 | { | ||
5663 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5664 | return false; | ||
5665 | } | ||
5666 | |||
5310 | if (position == Vector3.Zero) // Teleport | 5667 | if (position == Vector3.Zero) // Teleport |
5311 | { | 5668 | { |
5312 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5669 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5335,13 +5692,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5335 | } | 5692 | } |
5336 | } | 5693 | } |
5337 | } | 5694 | } |
5695 | |||
5696 | float posX = 128.0f; | ||
5697 | float posY = 128.0f; | ||
5698 | |||
5699 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5700 | { | ||
5701 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5702 | return false; | ||
5703 | } | ||
5704 | } | ||
5705 | else // Walking | ||
5706 | { | ||
5707 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5708 | if (land == null) | ||
5709 | return false; | ||
5710 | |||
5711 | bool banned = land.IsBannedFromLand(agentID); | ||
5712 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5713 | |||
5714 | if (banned || restricted) | ||
5715 | return false; | ||
5338 | } | 5716 | } |
5339 | 5717 | ||
5340 | reason = String.Empty; | 5718 | reason = String.Empty; |
5341 | return true; | 5719 | return true; |
5342 | } | 5720 | } |
5343 | 5721 | ||
5344 | /// <summary> | 5722 | public void StartTimerWatchdog() |
5723 | { | ||
5724 | m_timerWatchdog.Interval = 1000; | ||
5725 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5726 | m_timerWatchdog.AutoReset = true; | ||
5727 | m_timerWatchdog.Start(); | ||
5728 | } | ||
5729 | |||
5730 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5731 | { | ||
5732 | CheckHeartbeat(); | ||
5733 | } | ||
5734 | |||
5345 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5735 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5346 | /// autopilot that moves an avatar to a sit target!. | 5736 | /// autopilot that moves an avatar to a sit target!. |
5347 | /// </summary> | 5737 | /// </summary> |
@@ -5419,5 +5809,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
5419 | m_SpawnPoint = 1; | 5809 | m_SpawnPoint = 1; |
5420 | return m_SpawnPoint - 1; | 5810 | return m_SpawnPoint - 1; |
5421 | } | 5811 | } |
5812 | |||
5813 | private void HandleGcCollect(string module, string[] args) | ||
5814 | { | ||
5815 | GC.Collect(); | ||
5816 | } | ||
5422 | } | 5817 | } |
5423 | } | 5818 | } |