diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 812 |
1 files changed, 610 insertions, 202 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2b4dea4..5b529c3 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> |
@@ -2286,6 +2393,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2286 | } | 2393 | } |
2287 | 2394 | ||
2288 | group.DeleteGroupFromScene(silent); | 2395 | group.DeleteGroupFromScene(silent); |
2396 | if (!silent) | ||
2397 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2289 | 2398 | ||
2290 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2399 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2291 | } | 2400 | } |
@@ -2576,7 +2685,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2576 | // If the user is banned, we won't let any of their objects | 2685 | // If the user is banned, we won't let any of their objects |
2577 | // enter. Period. | 2686 | // enter. Period. |
2578 | // | 2687 | // |
2579 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2688 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2580 | { | 2689 | { |
2581 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2690 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2582 | return false; | 2691 | return false; |
@@ -2584,6 +2693,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2584 | 2693 | ||
2585 | if (newPosition != Vector3.Zero) | 2694 | if (newPosition != Vector3.Zero) |
2586 | newObject.RootPart.GroupPosition = newPosition; | 2695 | newObject.RootPart.GroupPosition = newPosition; |
2696 | if (newObject.RootPart.KeyframeMotion != null) | ||
2697 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2587 | 2698 | ||
2588 | if (!AddSceneObject(newObject)) | 2699 | if (!AddSceneObject(newObject)) |
2589 | { | 2700 | { |
@@ -2628,6 +2739,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2628 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2739 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2629 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2740 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2630 | { | 2741 | { |
2742 | if (sceneObject.OwnerID == UUID.Zero) | ||
2743 | { | ||
2744 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2745 | return false; | ||
2746 | } | ||
2747 | |||
2748 | // If the user is banned, we won't let any of their objects | ||
2749 | // enter. Period. | ||
2750 | // | ||
2751 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2752 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2753 | { | ||
2754 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2755 | |||
2756 | return false; | ||
2757 | } | ||
2758 | |||
2631 | // Force allocation of new LocalId | 2759 | // Force allocation of new LocalId |
2632 | // | 2760 | // |
2633 | SceneObjectPart[] parts = sceneObject.Parts; | 2761 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2661,16 +2789,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2661 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2789 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2662 | 2790 | ||
2663 | if (AttachmentsModule != null) | 2791 | if (AttachmentsModule != null) |
2664 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); | 2792 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); |
2665 | } | 2793 | } |
2666 | else | 2794 | else |
2667 | { | 2795 | { |
2796 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2668 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2797 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2669 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2798 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2670 | } | 2799 | } |
2800 | if (sceneObject.OwnerID == UUID.Zero) | ||
2801 | { | ||
2802 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2803 | return false; | ||
2804 | } | ||
2671 | } | 2805 | } |
2672 | else | 2806 | else |
2673 | { | 2807 | { |
2808 | if (sceneObject.OwnerID == UUID.Zero) | ||
2809 | { | ||
2810 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2811 | return false; | ||
2812 | } | ||
2674 | AddRestoredSceneObject(sceneObject, true, false); | 2813 | AddRestoredSceneObject(sceneObject, true, false); |
2675 | } | 2814 | } |
2676 | 2815 | ||
@@ -2687,6 +2826,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2687 | return 2; // StateSource.PrimCrossing | 2826 | return 2; // StateSource.PrimCrossing |
2688 | } | 2827 | } |
2689 | 2828 | ||
2829 | public int GetUserFlags(UUID user) | ||
2830 | { | ||
2831 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2832 | /* | ||
2833 | ScenePresence sp; | ||
2834 | if (TryGetScenePresence(user, out sp)) | ||
2835 | { | ||
2836 | return sp.UserFlags; | ||
2837 | } | ||
2838 | else | ||
2839 | { | ||
2840 | */ | ||
2841 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2842 | if (uac == null) | ||
2843 | return 0; | ||
2844 | return uac.UserFlags; | ||
2845 | //} | ||
2846 | } | ||
2690 | #endregion | 2847 | #endregion |
2691 | 2848 | ||
2692 | #region Add/Remove Avatar Methods | 2849 | #region Add/Remove Avatar Methods |
@@ -2700,7 +2857,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2700 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2857 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2701 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2858 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2702 | 2859 | ||
2703 | // CheckHeartbeat(); | 2860 | CheckHeartbeat(); |
2704 | 2861 | ||
2705 | ScenePresence sp = GetScenePresence(client.AgentId); | 2862 | ScenePresence sp = GetScenePresence(client.AgentId); |
2706 | 2863 | ||
@@ -2754,7 +2911,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2754 | 2911 | ||
2755 | EventManager.TriggerOnNewClient(client); | 2912 | EventManager.TriggerOnNewClient(client); |
2756 | if (vialogin) | 2913 | if (vialogin) |
2914 | { | ||
2757 | EventManager.TriggerOnClientLogin(client); | 2915 | EventManager.TriggerOnClientLogin(client); |
2916 | // Send initial parcel data | ||
2917 | Vector3 pos = sp.AbsolutePosition; | ||
2918 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2919 | land.SendLandUpdateToClient(client); | ||
2920 | } | ||
2758 | 2921 | ||
2759 | return sp; | 2922 | return sp; |
2760 | } | 2923 | } |
@@ -2843,19 +3006,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2843 | // and the scene presence and the client, if they exist | 3006 | // and the scene presence and the client, if they exist |
2844 | try | 3007 | try |
2845 | { | 3008 | { |
2846 | // We need to wait for the client to make UDP contact first. | 3009 | ScenePresence sp = GetScenePresence(agentID); |
2847 | // It's the UDP contact that creates the scene presence | 3010 | |
2848 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2849 | if (sp != null) | 3011 | if (sp != null) |
2850 | { | 3012 | { |
2851 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3013 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2852 | |||
2853 | sp.ControllingClient.Close(); | 3014 | sp.ControllingClient.Close(); |
2854 | } | 3015 | } |
2855 | else | 3016 | |
2856 | { | ||
2857 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2858 | } | ||
2859 | // BANG! SLASH! | 3017 | // BANG! SLASH! |
2860 | m_authenticateHandler.RemoveCircuit(agentID); | 3018 | m_authenticateHandler.RemoveCircuit(agentID); |
2861 | 3019 | ||
@@ -2900,6 +3058,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2900 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3058 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2901 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3059 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2902 | 3060 | ||
3061 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3062 | |||
2903 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3063 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2904 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3064 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2905 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3065 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2956,6 +3116,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2956 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3116 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2957 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3117 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2958 | client.OnCopyInventoryItem += CopyInventoryItem; | 3118 | client.OnCopyInventoryItem += CopyInventoryItem; |
3119 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2959 | client.OnMoveInventoryItem += MoveInventoryItem; | 3120 | client.OnMoveInventoryItem += MoveInventoryItem; |
2960 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3121 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2961 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3122 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3027,6 +3188,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3027 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3188 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3028 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3189 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3029 | 3190 | ||
3191 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3192 | |||
3030 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3193 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3031 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3194 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3032 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3195 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3129,7 +3292,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3129 | /// </summary> | 3292 | /// </summary> |
3130 | /// <param name="agentId">The avatar's Unique ID</param> | 3293 | /// <param name="agentId">The avatar's Unique ID</param> |
3131 | /// <param name="client">The IClientAPI for the client</param> | 3294 | /// <param name="client">The IClientAPI for the client</param> |
3132 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3295 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3133 | { | 3296 | { |
3134 | if (EntityTransferModule != null) | 3297 | if (EntityTransferModule != null) |
3135 | { | 3298 | { |
@@ -3140,6 +3303,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3140 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3303 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3141 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3304 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3142 | } | 3305 | } |
3306 | return false; | ||
3143 | } | 3307 | } |
3144 | 3308 | ||
3145 | /// <summary> | 3309 | /// <summary> |
@@ -3249,6 +3413,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3249 | /// <param name="flags"></param> | 3413 | /// <param name="flags"></param> |
3250 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3414 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3251 | { | 3415 | { |
3416 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3417 | ScenePresence presence; | ||
3418 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3419 | { | ||
3420 | if (presence.Appearance != null) | ||
3421 | { | ||
3422 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3423 | } | ||
3424 | } | ||
3425 | |||
3252 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3426 | 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. | 3427 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3254 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3428 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3365,6 +3539,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3365 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3539 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3366 | 3540 | ||
3367 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3541 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3542 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3368 | } | 3543 | } |
3369 | catch (Exception e) | 3544 | catch (Exception e) |
3370 | { | 3545 | { |
@@ -3562,17 +3737,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3562 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | 3737 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", |
3563 | sp.Name, sp.UUID, RegionInfo.RegionName); | 3738 | sp.Name, sp.UUID, RegionInfo.RegionName); |
3564 | 3739 | ||
3565 | sp.ControllingClient.Close(true); | 3740 | sp.ControllingClient.Close(true, true); |
3566 | sp = null; | 3741 | sp = null; |
3567 | } | 3742 | } |
3568 | 3743 | ||
3569 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3570 | 3744 | ||
3571 | //On login test land permisions | 3745 | //On login test land permisions |
3572 | if (vialogin) | 3746 | if (vialogin) |
3573 | { | 3747 | { |
3574 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3748 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3749 | if (cache != null) | ||
3750 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3751 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3575 | { | 3752 | { |
3753 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3576 | return false; | 3754 | return false; |
3577 | } | 3755 | } |
3578 | } | 3756 | } |
@@ -3595,9 +3773,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3595 | 3773 | ||
3596 | try | 3774 | try |
3597 | { | 3775 | { |
3598 | if (!AuthorizeUser(agent, out reason)) | 3776 | // Always check estate if this is a login. Always |
3599 | return false; | 3777 | // check if banned regions are to be blacked out. |
3600 | } catch (Exception e) | 3778 | if (vialogin || (!m_seeIntoBannedRegion)) |
3779 | { | ||
3780 | if (!AuthorizeUser(agent, out reason)) | ||
3781 | return false; | ||
3782 | } | ||
3783 | } | ||
3784 | catch (Exception e) | ||
3601 | { | 3785 | { |
3602 | m_log.ErrorFormat( | 3786 | m_log.ErrorFormat( |
3603 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3787 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3728,6 +3912,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3728 | } | 3912 | } |
3729 | 3913 | ||
3730 | // Honor parcel landing type and position. | 3914 | // Honor parcel landing type and position. |
3915 | /* | ||
3916 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3731 | if (land != null) | 3917 | if (land != null) |
3732 | { | 3918 | { |
3733 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3919 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3735,25 +3921,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
3735 | agent.startpos = land.LandData.UserLocation; | 3921 | agent.startpos = land.LandData.UserLocation; |
3736 | } | 3922 | } |
3737 | } | 3923 | } |
3924 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3738 | } | 3925 | } |
3739 | 3926 | ||
3740 | return true; | 3927 | return true; |
3741 | } | 3928 | } |
3742 | 3929 | ||
3743 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3930 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3744 | { | 3931 | { |
3745 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3932 | if (posX < 0) |
3746 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3933 | posX = 0; |
3934 | else if (posX >= 256) | ||
3935 | posX = 255.999f; | ||
3936 | if (posY < 0) | ||
3937 | posY = 0; | ||
3938 | else if (posY >= 256) | ||
3939 | posY = 255.999f; | ||
3940 | |||
3941 | reason = String.Empty; | ||
3942 | if (Permissions.IsGod(agentID)) | ||
3943 | return true; | ||
3944 | |||
3945 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3946 | if (land == null) | ||
3947 | return false; | ||
3948 | |||
3949 | bool banned = land.IsBannedFromLand(agentID); | ||
3950 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3747 | 3951 | ||
3748 | if (banned || restricted) | 3952 | if (banned || restricted) |
3749 | { | 3953 | { |
3750 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3954 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3751 | if (nearestParcel != null) | 3955 | if (nearestParcel != null) |
3752 | { | 3956 | { |
3753 | //Move agent to nearest allowed | 3957 | //Move agent to nearest allowed |
3754 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3958 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3755 | agent.startpos.X = newPosition.X; | 3959 | posX = newPosition.X; |
3756 | agent.startpos.Y = newPosition.Y; | 3960 | posY = newPosition.Y; |
3757 | } | 3961 | } |
3758 | else | 3962 | else |
3759 | { | 3963 | { |
@@ -3815,7 +4019,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3815 | 4019 | ||
3816 | if (!m_strictAccessControl) return true; | 4020 | if (!m_strictAccessControl) return true; |
3817 | if (Permissions.IsGod(agent.AgentID)) return true; | 4021 | if (Permissions.IsGod(agent.AgentID)) return true; |
3818 | 4022 | ||
3819 | if (AuthorizationService != null) | 4023 | if (AuthorizationService != null) |
3820 | { | 4024 | { |
3821 | if (!AuthorizationService.IsAuthorizedForRegion( | 4025 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3830,7 +4034,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3830 | 4034 | ||
3831 | if (RegionInfo.EstateSettings != null) | 4035 | if (RegionInfo.EstateSettings != null) |
3832 | { | 4036 | { |
3833 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4037 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3834 | { | 4038 | { |
3835 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4039 | 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); | 4040 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4020,6 +4224,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4020 | 4224 | ||
4021 | // XPTO: if this agent is not allowed here as root, always return false | 4225 | // XPTO: if this agent is not allowed here as root, always return false |
4022 | 4226 | ||
4227 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4228 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4229 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4230 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4231 | { | ||
4232 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4233 | return false; | ||
4234 | } | ||
4235 | |||
4023 | // TODO: This check should probably be in QueryAccess(). | 4236 | // TODO: This check should probably be in QueryAccess(). |
4024 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4237 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4025 | if (nearestParcel == null) | 4238 | if (nearestParcel == null) |
@@ -4083,7 +4296,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4083 | /// <param name='agentID'></param> | 4296 | /// <param name='agentID'></param> |
4084 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4297 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4085 | { | 4298 | { |
4086 | int ntimes = 10; | 4299 | int ntimes = 20; |
4087 | ScenePresence sp = null; | 4300 | ScenePresence sp = null; |
4088 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4301 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4089 | Thread.Sleep(1000); | 4302 | Thread.Sleep(1000); |
@@ -4113,6 +4326,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4113 | return false; | 4326 | return false; |
4114 | } | 4327 | } |
4115 | 4328 | ||
4329 | public bool IncomingCloseAgent(UUID agentID) | ||
4330 | { | ||
4331 | return IncomingCloseAgent(agentID, false); | ||
4332 | } | ||
4333 | |||
4334 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4335 | { | ||
4336 | return IncomingCloseAgent(agentID, true); | ||
4337 | } | ||
4338 | |||
4116 | /// <summary> | 4339 | /// <summary> |
4117 | /// Tell a single agent to disconnect from the region. | 4340 | /// Tell a single agent to disconnect from the region. |
4118 | /// </summary> | 4341 | /// </summary> |
@@ -4128,7 +4351,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4128 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4351 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4129 | if (presence != null) | 4352 | if (presence != null) |
4130 | { | 4353 | { |
4131 | presence.ControllingClient.Close(force); | 4354 | presence.ControllingClient.Close(true, force); |
4132 | return true; | 4355 | return true; |
4133 | } | 4356 | } |
4134 | 4357 | ||
@@ -4742,35 +4965,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4742 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 4965 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4743 | } | 4966 | } |
4744 | 4967 | ||
4745 | public int GetHealth() | 4968 | public int GetHealth(out int flags, out string message) |
4746 | { | 4969 | { |
4747 | // Returns: | 4970 | // Returns: |
4748 | // 1 = sim is up and accepting http requests. The heartbeat has | 4971 | // 1 = sim is up and accepting http requests. The heartbeat has |
4749 | // stopped and the sim is probably locked up, but a remote | 4972 | // stopped and the sim is probably locked up, but a remote |
4750 | // admin restart may succeed | 4973 | // admin restart may succeed |
4751 | // | 4974 | // |
4752 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4975 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4753 | // usable for people within and logins _may_ work | 4976 | // usable for people within |
4977 | // | ||
4978 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4979 | // unstable and will not accept new logins | ||
4754 | // | 4980 | // |
4755 | // 3 = We have seen a new user enter within the past 4 minutes | 4981 | // 4 = Sim is up and both packet threads are running. Sim is |
4982 | // likely usable | ||
4983 | // | ||
4984 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4756 | // which can be seen as positive confirmation of sim health | 4985 | // which can be seen as positive confirmation of sim health |
4757 | // | 4986 | // |
4987 | |||
4988 | flags = 0; | ||
4989 | message = String.Empty; | ||
4990 | |||
4991 | CheckHeartbeat(); | ||
4992 | |||
4993 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4994 | { | ||
4995 | // We're still starting | ||
4996 | // 0 means "in startup", it can't happen another way, since | ||
4997 | // to get here, we must be able to accept http connections | ||
4998 | return 0; | ||
4999 | } | ||
5000 | |||
4758 | int health=1; // Start at 1, means we're up | 5001 | int health=1; // Start at 1, means we're up |
4759 | 5002 | ||
4760 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5003 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4761 | health += 1; | 5004 | { |
5005 | health+=1; | ||
5006 | flags |= 1; | ||
5007 | } | ||
5008 | |||
5009 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5010 | { | ||
5011 | health+=1; | ||
5012 | flags |= 2; | ||
5013 | } | ||
5014 | |||
5015 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5016 | { | ||
5017 | health+=1; | ||
5018 | flags |= 4; | ||
5019 | } | ||
4762 | else | 5020 | else |
5021 | { | ||
5022 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5023 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5024 | proc.EnableRaisingEvents=false; | ||
5025 | proc.StartInfo.FileName = "/bin/kill"; | ||
5026 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5027 | proc.Start(); | ||
5028 | proc.WaitForExit(); | ||
5029 | Thread.Sleep(1000); | ||
5030 | Environment.Exit(1); | ||
5031 | } | ||
5032 | |||
5033 | if (flags != 7) | ||
4763 | return health; | 5034 | return health; |
4764 | 5035 | ||
4765 | // A login in the last 4 mins? We can't be doing too badly | 5036 | // A login in the last 4 mins? We can't be doing too badly |
4766 | // | 5037 | // |
4767 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5038 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4768 | health++; | 5039 | health++; |
4769 | else | 5040 | else |
4770 | return health; | 5041 | return health; |
4771 | 5042 | ||
4772 | // CheckHeartbeat(); | ||
4773 | |||
4774 | return health; | 5043 | return health; |
4775 | } | 5044 | } |
4776 | 5045 | ||
@@ -4858,7 +5127,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4858 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5127 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4859 | if (wasUsingPhysics) | 5128 | if (wasUsingPhysics) |
4860 | { | 5129 | { |
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 | 5130 | 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 | } | 5131 | } |
4863 | } | 5132 | } |
4864 | 5133 | ||
@@ -4957,14 +5226,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4957 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5226 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4958 | } | 5227 | } |
4959 | 5228 | ||
4960 | // private void CheckHeartbeat() | 5229 | private void CheckHeartbeat() |
4961 | // { | 5230 | { |
4962 | // if (m_firstHeartbeat) | 5231 | if (m_firstHeartbeat) |
4963 | // return; | 5232 | return; |
4964 | // | 5233 | |
4965 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5234 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4966 | // StartTimer(); | 5235 | Start(); |
4967 | // } | 5236 | } |
4968 | 5237 | ||
4969 | public override ISceneObject DeserializeObject(string representation) | 5238 | public override ISceneObject DeserializeObject(string representation) |
4970 | { | 5239 | { |
@@ -4976,9 +5245,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4976 | get { return m_allowScriptCrossings; } | 5245 | get { return m_allowScriptCrossings; } |
4977 | } | 5246 | } |
4978 | 5247 | ||
4979 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5248 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5249 | { | ||
5250 | return GetNearestAllowedPosition(avatar, null); | ||
5251 | } | ||
5252 | |||
5253 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4980 | { | 5254 | { |
4981 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5255 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4982 | 5256 | ||
4983 | if (nearestParcel != null) | 5257 | if (nearestParcel != null) |
4984 | { | 5258 | { |
@@ -4987,10 +5261,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4987 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5261 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4988 | if (nearestPoint != null) | 5262 | if (nearestPoint != null) |
4989 | { | 5263 | { |
4990 | // m_log.DebugFormat( | 5264 | 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; | 5265 | return nearestPoint.Value; |
4995 | } | 5266 | } |
4996 | 5267 | ||
@@ -5000,17 +5271,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
5000 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5271 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5001 | if (nearestPoint != null) | 5272 | if (nearestPoint != null) |
5002 | { | 5273 | { |
5003 | // m_log.DebugFormat( | 5274 | 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; | 5275 | return nearestPoint.Value; |
5007 | } | 5276 | } |
5008 | 5277 | ||
5009 | //Ultimate backup if we have no idea where they are | 5278 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
5010 | // m_log.DebugFormat( | 5279 | if (dest != excludeParcel) |
5011 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5280 | { |
5281 | // Ultimate backup if we have no idea where they are and | ||
5282 | // the last allowed position was in another parcel | ||
5283 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5284 | return avatar.lastKnownAllowedPosition; | ||
5285 | } | ||
5012 | 5286 | ||
5013 | return avatar.lastKnownAllowedPosition; | 5287 | // else fall through to region edge |
5014 | } | 5288 | } |
5015 | 5289 | ||
5016 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5290 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -5044,13 +5318,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5044 | 5318 | ||
5045 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5319 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
5046 | { | 5320 | { |
5321 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5322 | } | ||
5323 | |||
5324 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5325 | { | ||
5047 | List<ILandObject> all = AllParcels(); | 5326 | List<ILandObject> all = AllParcels(); |
5048 | float minParcelDistance = float.MaxValue; | 5327 | float minParcelDistance = float.MaxValue; |
5049 | ILandObject nearestParcel = null; | 5328 | ILandObject nearestParcel = null; |
5050 | 5329 | ||
5051 | foreach (var parcel in all) | 5330 | foreach (var parcel in all) |
5052 | { | 5331 | { |
5053 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5332 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
5054 | { | 5333 | { |
5055 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5334 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
5056 | if (parcelDistance < minParcelDistance) | 5335 | if (parcelDistance < minParcelDistance) |
@@ -5292,7 +5571,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5292 | mapModule.GenerateMaptile(); | 5571 | mapModule.GenerateMaptile(); |
5293 | } | 5572 | } |
5294 | 5573 | ||
5295 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5574 | // public void CleanDroppedAttachments() |
5575 | // { | ||
5576 | // List<SceneObjectGroup> objectsToDelete = | ||
5577 | // new List<SceneObjectGroup>(); | ||
5578 | // | ||
5579 | // lock (m_cleaningAttachments) | ||
5580 | // { | ||
5581 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5582 | // { | ||
5583 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5584 | // { | ||
5585 | // UUID agentID = grp.OwnerID; | ||
5586 | // if (agentID == UUID.Zero) | ||
5587 | // { | ||
5588 | // objectsToDelete.Add(grp); | ||
5589 | // return; | ||
5590 | // } | ||
5591 | // | ||
5592 | // ScenePresence sp = GetScenePresence(agentID); | ||
5593 | // if (sp == null) | ||
5594 | // { | ||
5595 | // objectsToDelete.Add(grp); | ||
5596 | // return; | ||
5597 | // } | ||
5598 | // } | ||
5599 | // }); | ||
5600 | // } | ||
5601 | // | ||
5602 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5603 | // { | ||
5604 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5605 | // DeleteSceneObject(grp, true); | ||
5606 | // } | ||
5607 | // } | ||
5608 | |||
5609 | public void ThreadAlive(int threadCode) | ||
5610 | { | ||
5611 | switch(threadCode) | ||
5612 | { | ||
5613 | case 1: // Incoming | ||
5614 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5615 | break; | ||
5616 | case 2: // Incoming | ||
5617 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5618 | break; | ||
5619 | } | ||
5620 | } | ||
5621 | |||
5622 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5296 | { | 5623 | { |
5297 | RegenerateMaptile(); | 5624 | RegenerateMaptile(); |
5298 | 5625 | ||
@@ -5320,6 +5647,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5320 | /// <returns></returns> | 5647 | /// <returns></returns> |
5321 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5648 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5322 | { | 5649 | { |
5650 | reason = "You are banned from the region"; | ||
5651 | |||
5323 | if (EntityTransferModule.IsInTransit(agentID)) | 5652 | if (EntityTransferModule.IsInTransit(agentID)) |
5324 | { | 5653 | { |
5325 | reason = "Agent is still in transit from this region"; | 5654 | reason = "Agent is still in transit from this region"; |
@@ -5331,6 +5660,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5331 | return false; | 5660 | return false; |
5332 | } | 5661 | } |
5333 | 5662 | ||
5663 | if (Permissions.IsGod(agentID)) | ||
5664 | { | ||
5665 | reason = String.Empty; | ||
5666 | return true; | ||
5667 | } | ||
5668 | |||
5334 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5669 | // 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. | 5670 | // However, the long term fix is to make sure root agent count is always accurate. |
5336 | m_sceneGraph.RecalculateStats(); | 5671 | m_sceneGraph.RecalculateStats(); |
@@ -5351,6 +5686,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5351 | } | 5686 | } |
5352 | } | 5687 | } |
5353 | 5688 | ||
5689 | ScenePresence presence = GetScenePresence(agentID); | ||
5690 | IClientAPI client = null; | ||
5691 | AgentCircuitData aCircuit = null; | ||
5692 | |||
5693 | if (presence != null) | ||
5694 | { | ||
5695 | client = presence.ControllingClient; | ||
5696 | if (client != null) | ||
5697 | aCircuit = client.RequestClientInfo(); | ||
5698 | } | ||
5699 | |||
5700 | // We may be called before there is a presence or a client. | ||
5701 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5702 | if (client == null) | ||
5703 | { | ||
5704 | aCircuit = new AgentCircuitData(); | ||
5705 | aCircuit.AgentID = agentID; | ||
5706 | aCircuit.firstname = String.Empty; | ||
5707 | aCircuit.lastname = String.Empty; | ||
5708 | } | ||
5709 | |||
5710 | try | ||
5711 | { | ||
5712 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5713 | { | ||
5714 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5715 | return false; | ||
5716 | } | ||
5717 | } | ||
5718 | catch (Exception e) | ||
5719 | { | ||
5720 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5721 | return false; | ||
5722 | } | ||
5723 | |||
5354 | if (position == Vector3.Zero) // Teleport | 5724 | if (position == Vector3.Zero) // Teleport |
5355 | { | 5725 | { |
5356 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5726 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5379,13 +5749,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5379 | } | 5749 | } |
5380 | } | 5750 | } |
5381 | } | 5751 | } |
5752 | |||
5753 | float posX = 128.0f; | ||
5754 | float posY = 128.0f; | ||
5755 | |||
5756 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5757 | { | ||
5758 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5759 | return false; | ||
5760 | } | ||
5761 | } | ||
5762 | else // Walking | ||
5763 | { | ||
5764 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5765 | if (land == null) | ||
5766 | return false; | ||
5767 | |||
5768 | bool banned = land.IsBannedFromLand(agentID); | ||
5769 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5770 | |||
5771 | if (banned || restricted) | ||
5772 | return false; | ||
5382 | } | 5773 | } |
5383 | 5774 | ||
5384 | reason = String.Empty; | 5775 | reason = String.Empty; |
5385 | return true; | 5776 | return true; |
5386 | } | 5777 | } |
5387 | 5778 | ||
5388 | /// <summary> | 5779 | public void StartTimerWatchdog() |
5780 | { | ||
5781 | m_timerWatchdog.Interval = 1000; | ||
5782 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5783 | m_timerWatchdog.AutoReset = true; | ||
5784 | m_timerWatchdog.Start(); | ||
5785 | } | ||
5786 | |||
5787 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5788 | { | ||
5789 | CheckHeartbeat(); | ||
5790 | } | ||
5791 | |||
5389 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5792 | /// 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!. | 5793 | /// autopilot that moves an avatar to a sit target!. |
5391 | /// </summary> | 5794 | /// </summary> |
@@ -5464,6 +5867,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5464 | return m_SpawnPoint - 1; | 5867 | return m_SpawnPoint - 1; |
5465 | } | 5868 | } |
5466 | 5869 | ||
5870 | private void HandleGcCollect(string module, string[] args) | ||
5871 | { | ||
5872 | GC.Collect(); | ||
5873 | } | ||
5874 | |||
5467 | // Wrappers to get physics modules retrieve assets. Has to be done this way | 5875 | // 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 | 5876 | // 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 | 5877 | // time physics are instantiated it's not registered but it will be by |