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