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