diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 697 |
1 files changed, 535 insertions, 162 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 293c72a..78edeb0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | // TODO: need to figure out how allow client agents but deny | 124 | // TODO: need to figure out how allow client agents but deny |
125 | // root agents when ACL denies access to root agent | 125 | // root agents when ACL denies access to root agent |
126 | public bool m_strictAccessControl = true; | 126 | public bool m_strictAccessControl = true; |
127 | public bool m_seeIntoBannedRegion = false; | ||
127 | public int MaxUndoCount = 5; | 128 | public int MaxUndoCount = 5; |
128 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 129 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
129 | public bool LoginLock = false; | 130 | public bool LoginLock = false; |
@@ -139,12 +140,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
139 | 140 | ||
140 | protected int m_splitRegionID; | 141 | protected int m_splitRegionID; |
141 | protected Timer m_restartWaitTimer = new Timer(); | 142 | protected Timer m_restartWaitTimer = new Timer(); |
143 | protected Timer m_timerWatchdog = new Timer(); | ||
142 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 144 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
143 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 145 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
144 | protected string m_simulatorVersion = "OpenSimulator Server"; | 146 | protected string m_simulatorVersion = "OpenSimulator Server"; |
145 | protected ModuleLoader m_moduleLoader; | 147 | protected ModuleLoader m_moduleLoader; |
146 | protected AgentCircuitManager m_authenticateHandler; | 148 | protected AgentCircuitManager m_authenticateHandler; |
147 | protected SceneCommunicationService m_sceneGridService; | 149 | protected SceneCommunicationService m_sceneGridService; |
150 | protected ISnmpModule m_snmpService = null; | ||
148 | 151 | ||
149 | protected ISimulationDataService m_SimulationDataService; | 152 | protected ISimulationDataService m_SimulationDataService; |
150 | protected IEstateDataService m_EstateDataService; | 153 | protected IEstateDataService m_EstateDataService; |
@@ -206,7 +209,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | private int m_update_events = 1; | 209 | private int m_update_events = 1; |
207 | private int m_update_backup = 200; | 210 | private int m_update_backup = 200; |
208 | private int m_update_terrain = 50; | 211 | private int m_update_terrain = 50; |
209 | // private int m_update_land = 1; | 212 | private int m_update_land = 10; |
210 | private int m_update_coarse_locations = 50; | 213 | private int m_update_coarse_locations = 50; |
211 | 214 | ||
212 | private int agentMS; | 215 | private int agentMS; |
@@ -226,6 +229,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | /// </summary> | 229 | /// </summary> |
227 | private int m_lastFrameTick; | 230 | private int m_lastFrameTick; |
228 | 231 | ||
232 | public bool CombineRegions = false; | ||
229 | /// <summary> | 233 | /// <summary> |
230 | /// Tick at which the last maintenance run occurred. | 234 | /// Tick at which the last maintenance run occurred. |
231 | /// </summary> | 235 | /// </summary> |
@@ -256,6 +260,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
256 | /// </summary> | 260 | /// </summary> |
257 | private int m_LastLogin; | 261 | private int m_LastLogin; |
258 | 262 | ||
263 | private int m_lastIncoming; | ||
264 | private int m_lastOutgoing; | ||
265 | private int m_hbRestarts = 0; | ||
266 | |||
267 | |||
259 | /// <summary> | 268 | /// <summary> |
260 | /// Thread that runs the scene loop. | 269 | /// Thread that runs the scene loop. |
261 | /// </summary> | 270 | /// </summary> |
@@ -271,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
271 | private volatile bool m_shuttingDown; | 280 | private volatile bool m_shuttingDown; |
272 | 281 | ||
273 | // private int m_lastUpdate; | 282 | // private int m_lastUpdate; |
274 | // private bool m_firstHeartbeat = true; | 283 | private bool m_firstHeartbeat = true; |
275 | 284 | ||
276 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 285 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
277 | private bool m_reprioritizationEnabled = true; | 286 | private bool m_reprioritizationEnabled = true; |
@@ -316,6 +325,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
316 | get { return m_sceneGridService; } | 325 | get { return m_sceneGridService; } |
317 | } | 326 | } |
318 | 327 | ||
328 | public ISnmpModule SnmpService | ||
329 | { | ||
330 | get | ||
331 | { | ||
332 | if (m_snmpService == null) | ||
333 | { | ||
334 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
335 | } | ||
336 | |||
337 | return m_snmpService; | ||
338 | } | ||
339 | } | ||
340 | |||
319 | public ISimulationDataService SimulationDataService | 341 | public ISimulationDataService SimulationDataService |
320 | { | 342 | { |
321 | get | 343 | get |
@@ -614,7 +636,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
614 | m_sceneGridService = sceneGridService; | 636 | m_sceneGridService = sceneGridService; |
615 | m_SimulationDataService = simDataService; | 637 | m_SimulationDataService = simDataService; |
616 | m_EstateDataService = estateDataService; | 638 | m_EstateDataService = estateDataService; |
617 | m_regionHandle = RegionInfo.RegionHandle; | 639 | m_regionHandle = m_regInfo.RegionHandle; |
640 | m_lastIncoming = 0; | ||
641 | m_lastOutgoing = 0; | ||
618 | 642 | ||
619 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 643 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
620 | m_asyncSceneObjectDeleter.Enabled = true; | 644 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -695,102 +719,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
695 | 719 | ||
696 | // Region config overrides global config | 720 | // Region config overrides global config |
697 | // | 721 | // |
698 | if (m_config.Configs["Startup"] != null) | 722 | try |
699 | { | 723 | { |
700 | IConfig startupConfig = m_config.Configs["Startup"]; | 724 | if (m_config.Configs["Startup"] != null) |
701 | |||
702 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | ||
703 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | ||
704 | if (!m_useBackup) | ||
705 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | ||
706 | |||
707 | //Animation states | ||
708 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
709 | |||
710 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
711 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
712 | |||
713 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | ||
714 | if (RegionInfo.NonphysPrimMax > 0) | ||
715 | { | 725 | { |
716 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 726 | IConfig startupConfig = m_config.Configs["Startup"]; |
717 | } | ||
718 | |||
719 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | ||
720 | 727 | ||
721 | if (RegionInfo.PhysPrimMax > 0) | 728 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
722 | { | 729 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
723 | m_maxPhys = RegionInfo.PhysPrimMax; | 730 | if (!m_useBackup) |
724 | } | 731 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
732 | |||
733 | //Animation states | ||
734 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
725 | 735 | ||
726 | // Here, if clamping is requested in either global or | 736 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
727 | // local config, it will be used | 737 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
728 | // | ||
729 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | ||
730 | if (RegionInfo.ClampPrimSize) | ||
731 | { | ||
732 | m_clampPrimSize = true; | ||
733 | } | ||
734 | 738 | ||
735 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | 739 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
736 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 740 | if (RegionInfo.NonphysPrimMax > 0) |
737 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 741 | { |
738 | m_dontPersistBefore = | 742 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
739 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | 743 | } |
740 | m_dontPersistBefore *= 10000000; | ||
741 | m_persistAfter = | ||
742 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
743 | m_persistAfter *= 10000000; | ||
744 | 744 | ||
745 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 745 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
746 | 746 | ||
747 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | 747 | if (RegionInfo.PhysPrimMax > 0) |
748 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | 748 | { |
749 | m_maxPhys = RegionInfo.PhysPrimMax; | ||
750 | } | ||
749 | 751 | ||
750 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 752 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); |
751 | if (packetConfig != null) | 753 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); |
752 | { | ||
753 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | ||
754 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | ||
755 | } | ||
756 | 754 | ||
757 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 755 | // Here, if clamping is requested in either global or |
756 | // local config, it will be used | ||
757 | // | ||
758 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | ||
759 | if (RegionInfo.ClampPrimSize) | ||
760 | { | ||
761 | m_clampPrimSize = true; | ||
762 | } | ||
758 | 763 | ||
759 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 764 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
760 | if (m_generateMaptiles) | 765 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
761 | { | 766 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
762 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | 767 | m_dontPersistBefore = |
763 | if (maptileRefresh != 0) | 768 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); |
769 | m_dontPersistBefore *= 10000000; | ||
770 | m_persistAfter = | ||
771 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
772 | m_persistAfter *= 10000000; | ||
773 | |||
774 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | ||
775 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
776 | |||
777 | IConfig packetConfig = m_config.Configs["PacketPool"]; | ||
778 | if (packetConfig != null) | ||
764 | { | 779 | { |
765 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 780 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
766 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | 781 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); |
767 | m_mapGenerationTimer.AutoReset = true; | ||
768 | m_mapGenerationTimer.Start(); | ||
769 | } | 782 | } |
770 | } | ||
771 | else | ||
772 | { | ||
773 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
774 | UUID tileID; | ||
775 | 783 | ||
776 | if (UUID.TryParse(tile, out tileID)) | 784 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
785 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
786 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
787 | |||
788 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | ||
789 | if (m_generateMaptiles) | ||
777 | { | 790 | { |
778 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 791 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
792 | if (maptileRefresh != 0) | ||
793 | { | ||
794 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | ||
795 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
796 | m_mapGenerationTimer.AutoReset = true; | ||
797 | m_mapGenerationTimer.Start(); | ||
798 | } | ||
779 | } | 799 | } |
780 | } | 800 | else |
801 | { | ||
802 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
803 | UUID tileID; | ||
781 | 804 | ||
782 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 805 | if (UUID.TryParse(tile, out tileID)) |
783 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 806 | { |
784 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 807 | RegionInfo.RegionSettings.TerrainImageID = tileID; |
785 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 808 | } |
786 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 809 | } |
787 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
788 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
789 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
790 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
791 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
792 | 810 | ||
793 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | 811 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
812 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | ||
813 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | ||
814 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | ||
815 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | ||
816 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
817 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
818 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
819 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
820 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
821 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | ||
822 | } | ||
823 | } | ||
824 | catch (Exception e) | ||
825 | { | ||
826 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
794 | } | 827 | } |
795 | 828 | ||
796 | #endregion Region Config | 829 | #endregion Region Config |
@@ -1216,7 +1249,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1216 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1249 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1217 | if (m_heartbeatThread != null) | 1250 | if (m_heartbeatThread != null) |
1218 | { | 1251 | { |
1252 | m_hbRestarts++; | ||
1253 | if(m_hbRestarts > 10) | ||
1254 | Environment.Exit(1); | ||
1255 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1256 | |||
1257 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1258 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1259 | //proc.EnableRaisingEvents=false; | ||
1260 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1261 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1262 | //proc.Start(); | ||
1263 | //proc.WaitForExit(); | ||
1264 | //Thread.Sleep(1000); | ||
1265 | //Environment.Exit(1); | ||
1219 | m_heartbeatThread.Abort(); | 1266 | m_heartbeatThread.Abort(); |
1267 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1220 | m_heartbeatThread = null; | 1268 | m_heartbeatThread = null; |
1221 | } | 1269 | } |
1222 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1270 | // m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1507,6 +1555,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1507 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1555 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); |
1508 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1556 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1509 | 1557 | ||
1558 | m_firstHeartbeat = false; | ||
1559 | |||
1510 | if (tmpMS > 0) | 1560 | if (tmpMS > 0) |
1511 | { | 1561 | { |
1512 | Thread.Sleep(tmpMS); | 1562 | Thread.Sleep(tmpMS); |
@@ -1557,9 +1607,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1557 | 1607 | ||
1558 | private void CheckAtTargets() | 1608 | private void CheckAtTargets() |
1559 | { | 1609 | { |
1560 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1610 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1561 | lock (m_groupsWithTargets) | 1611 | lock (m_groupsWithTargets) |
1562 | objs = m_groupsWithTargets.Values; | 1612 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1563 | 1613 | ||
1564 | foreach (SceneObjectGroup entry in objs) | 1614 | foreach (SceneObjectGroup entry in objs) |
1565 | entry.checkAtTargets(); | 1615 | entry.checkAtTargets(); |
@@ -1640,7 +1690,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1640 | msg.fromAgentName = "Server"; | 1690 | msg.fromAgentName = "Server"; |
1641 | msg.dialog = (byte)19; // Object msg | 1691 | msg.dialog = (byte)19; // Object msg |
1642 | msg.fromGroup = false; | 1692 | msg.fromGroup = false; |
1643 | msg.offline = (byte)0; | 1693 | msg.offline = (byte)1; |
1644 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1694 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1645 | msg.Position = Vector3.Zero; | 1695 | msg.Position = Vector3.Zero; |
1646 | msg.RegionID = RegionInfo.RegionID.Guid; | 1696 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1862,6 +1912,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1862 | EventManager.TriggerPrimsLoaded(this); | 1912 | EventManager.TriggerPrimsLoaded(this); |
1863 | } | 1913 | } |
1864 | 1914 | ||
1915 | public bool SuportsRayCastFiltered() | ||
1916 | { | ||
1917 | if (PhysicsScene == null) | ||
1918 | return false; | ||
1919 | return PhysicsScene.SuportsRaycastWorldFiltered(); | ||
1920 | } | ||
1921 | |||
1922 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | ||
1923 | { | ||
1924 | if (PhysicsScene == null) | ||
1925 | return null; | ||
1926 | return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); | ||
1927 | } | ||
1865 | 1928 | ||
1866 | /// <summary> | 1929 | /// <summary> |
1867 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. | 1930 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. |
@@ -1878,14 +1941,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1878 | /// <returns></returns> | 1941 | /// <returns></returns> |
1879 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1942 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1880 | { | 1943 | { |
1944 | |||
1945 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1946 | Vector3 wpos = Vector3.Zero; | ||
1947 | // Check for water surface intersection from above | ||
1948 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1949 | { | ||
1950 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1951 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1952 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1953 | wpos.Z = wheight; | ||
1954 | } | ||
1955 | |||
1881 | Vector3 pos = Vector3.Zero; | 1956 | Vector3 pos = Vector3.Zero; |
1882 | if (RayEndIsIntersection == (byte)1) | 1957 | if (RayEndIsIntersection == (byte)1) |
1883 | { | 1958 | { |
1884 | pos = RayEnd; | 1959 | pos = RayEnd; |
1885 | return pos; | ||
1886 | } | 1960 | } |
1887 | 1961 | else if (RayTargetID != UUID.Zero) | |
1888 | if (RayTargetID != UUID.Zero) | ||
1889 | { | 1962 | { |
1890 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1963 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1891 | 1964 | ||
@@ -1907,7 +1980,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1907 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1980 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1908 | 1981 | ||
1909 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1982 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1910 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1983 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1911 | float ScaleOffset = 0.5f; | 1984 | float ScaleOffset = 0.5f; |
1912 | 1985 | ||
1913 | // If we hit something | 1986 | // If we hit something |
@@ -1930,13 +2003,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1930 | //pos.Z -= 0.25F; | 2003 | //pos.Z -= 0.25F; |
1931 | 2004 | ||
1932 | } | 2005 | } |
1933 | |||
1934 | return pos; | ||
1935 | } | 2006 | } |
1936 | else | 2007 | else |
1937 | { | 2008 | { |
1938 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2009 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1939 | |||
1940 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2010 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1941 | 2011 | ||
1942 | // Un-comment the following line to print the raytrace results to the console. | 2012 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1945,13 +2015,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1945 | if (ei.HitTF) | 2015 | if (ei.HitTF) |
1946 | { | 2016 | { |
1947 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2017 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1948 | } else | 2018 | } |
2019 | else | ||
1949 | { | 2020 | { |
1950 | // fall back to our stupid functionality | 2021 | // fall back to our stupid functionality |
1951 | pos = RayEnd; | 2022 | pos = RayEnd; |
1952 | } | 2023 | } |
1953 | |||
1954 | return pos; | ||
1955 | } | 2024 | } |
1956 | } | 2025 | } |
1957 | else | 2026 | else |
@@ -1962,8 +2031,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1962 | //increase height so its above the ground. | 2031 | //increase height so its above the ground. |
1963 | //should be getting the normal of the ground at the rez point and using that? | 2032 | //should be getting the normal of the ground at the rez point and using that? |
1964 | pos.Z += scale.Z / 2f; | 2033 | pos.Z += scale.Z / 2f; |
1965 | return pos; | 2034 | // return pos; |
1966 | } | 2035 | } |
2036 | |||
2037 | // check against posible water intercept | ||
2038 | if (wpos.Z > pos.Z) pos = wpos; | ||
2039 | return pos; | ||
1967 | } | 2040 | } |
1968 | 2041 | ||
1969 | 2042 | ||
@@ -2052,7 +2125,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2052 | public bool AddRestoredSceneObject( | 2125 | public bool AddRestoredSceneObject( |
2053 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2126 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
2054 | { | 2127 | { |
2055 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2128 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2129 | if (result) | ||
2130 | sceneObject.IsDeleted = false; | ||
2131 | return result; | ||
2056 | } | 2132 | } |
2057 | 2133 | ||
2058 | /// <summary> | 2134 | /// <summary> |
@@ -2144,6 +2220,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2144 | /// </summary> | 2220 | /// </summary> |
2145 | public void DeleteAllSceneObjects() | 2221 | public void DeleteAllSceneObjects() |
2146 | { | 2222 | { |
2223 | DeleteAllSceneObjects(false); | ||
2224 | } | ||
2225 | |||
2226 | /// <summary> | ||
2227 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2228 | /// </summary> | ||
2229 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2230 | { | ||
2231 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2147 | lock (Entities) | 2232 | lock (Entities) |
2148 | { | 2233 | { |
2149 | EntityBase[] entities = Entities.GetEntities(); | 2234 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2152,11 +2237,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2152 | if (e is SceneObjectGroup) | 2237 | if (e is SceneObjectGroup) |
2153 | { | 2238 | { |
2154 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2239 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2155 | if (!sog.IsAttachment) | 2240 | if (sog != null && !sog.IsAttachment) |
2156 | DeleteSceneObject((SceneObjectGroup)e, false); | 2241 | { |
2242 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2243 | { | ||
2244 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2245 | } | ||
2246 | else | ||
2247 | { | ||
2248 | toReturn.Add((SceneObjectGroup)e); | ||
2249 | } | ||
2250 | } | ||
2157 | } | 2251 | } |
2158 | } | 2252 | } |
2159 | } | 2253 | } |
2254 | if (toReturn.Count > 0) | ||
2255 | { | ||
2256 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2257 | } | ||
2160 | } | 2258 | } |
2161 | 2259 | ||
2162 | /// <summary> | 2260 | /// <summary> |
@@ -2191,6 +2289,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2191 | } | 2289 | } |
2192 | 2290 | ||
2193 | group.DeleteGroupFromScene(silent); | 2291 | group.DeleteGroupFromScene(silent); |
2292 | if (!silent) | ||
2293 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2194 | 2294 | ||
2195 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2295 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2196 | } | 2296 | } |
@@ -2480,6 +2580,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2480 | 2580 | ||
2481 | if (newPosition != Vector3.Zero) | 2581 | if (newPosition != Vector3.Zero) |
2482 | newObject.RootPart.GroupPosition = newPosition; | 2582 | newObject.RootPart.GroupPosition = newPosition; |
2583 | if (newObject.RootPart.KeyframeMotion != null) | ||
2584 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2483 | 2585 | ||
2484 | if (!AddSceneObject(newObject)) | 2586 | if (!AddSceneObject(newObject)) |
2485 | { | 2587 | { |
@@ -2510,10 +2612,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2510 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2612 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2511 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2613 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2512 | { | 2614 | { |
2615 | if (sceneObject.OwnerID == UUID.Zero) | ||
2616 | { | ||
2617 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2618 | return false; | ||
2619 | } | ||
2620 | |||
2513 | // If the user is banned, we won't let any of their objects | 2621 | // If the user is banned, we won't let any of their objects |
2514 | // enter. Period. | 2622 | // enter. Period. |
2515 | // | 2623 | // |
2516 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2624 | int flags = GetUserFlags(sceneObject.OwnerID); |
2625 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2517 | { | 2626 | { |
2518 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2627 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2519 | 2628 | ||
@@ -2555,16 +2664,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2555 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2664 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2556 | 2665 | ||
2557 | if (AttachmentsModule != null) | 2666 | if (AttachmentsModule != null) |
2558 | AttachmentsModule.AttachObject(sp, grp, 0, false); | 2667 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); |
2559 | } | 2668 | } |
2560 | else | 2669 | else |
2561 | { | 2670 | { |
2671 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2562 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2672 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2563 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2673 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2564 | } | 2674 | } |
2675 | if (sceneObject.OwnerID == UUID.Zero) | ||
2676 | { | ||
2677 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2678 | return false; | ||
2679 | } | ||
2565 | } | 2680 | } |
2566 | else | 2681 | else |
2567 | { | 2682 | { |
2683 | if (sceneObject.OwnerID == UUID.Zero) | ||
2684 | { | ||
2685 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2686 | return false; | ||
2687 | } | ||
2568 | AddRestoredSceneObject(sceneObject, true, false); | 2688 | AddRestoredSceneObject(sceneObject, true, false); |
2569 | 2689 | ||
2570 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2690 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2593,6 +2713,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2593 | return 2; // StateSource.PrimCrossing | 2713 | return 2; // StateSource.PrimCrossing |
2594 | } | 2714 | } |
2595 | 2715 | ||
2716 | public int GetUserFlags(UUID user) | ||
2717 | { | ||
2718 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2719 | /* | ||
2720 | ScenePresence sp; | ||
2721 | if (TryGetScenePresence(user, out sp)) | ||
2722 | { | ||
2723 | return sp.UserFlags; | ||
2724 | } | ||
2725 | else | ||
2726 | { | ||
2727 | */ | ||
2728 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2729 | if (uac == null) | ||
2730 | return 0; | ||
2731 | return uac.UserFlags; | ||
2732 | //} | ||
2733 | } | ||
2596 | #endregion | 2734 | #endregion |
2597 | 2735 | ||
2598 | #region Add/Remove Avatar Methods | 2736 | #region Add/Remove Avatar Methods |
@@ -2606,7 +2744,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2606 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2744 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2607 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2745 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2608 | 2746 | ||
2609 | // CheckHeartbeat(); | 2747 | CheckHeartbeat(); |
2610 | 2748 | ||
2611 | ScenePresence sp = GetScenePresence(client.AgentId); | 2749 | ScenePresence sp = GetScenePresence(client.AgentId); |
2612 | 2750 | ||
@@ -2660,7 +2798,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2660 | 2798 | ||
2661 | EventManager.TriggerOnNewClient(client); | 2799 | EventManager.TriggerOnNewClient(client); |
2662 | if (vialogin) | 2800 | if (vialogin) |
2801 | { | ||
2663 | EventManager.TriggerOnClientLogin(client); | 2802 | EventManager.TriggerOnClientLogin(client); |
2803 | // Send initial parcel data | ||
2804 | Vector3 pos = sp.AbsolutePosition; | ||
2805 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2806 | land.SendLandUpdateToClient(client); | ||
2807 | } | ||
2664 | 2808 | ||
2665 | return sp; | 2809 | return sp; |
2666 | } | 2810 | } |
@@ -2749,19 +2893,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2749 | // and the scene presence and the client, if they exist | 2893 | // and the scene presence and the client, if they exist |
2750 | try | 2894 | try |
2751 | { | 2895 | { |
2752 | // We need to wait for the client to make UDP contact first. | 2896 | ScenePresence sp = GetScenePresence(agentID); |
2753 | // It's the UDP contact that creates the scene presence | 2897 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2754 | ScenePresence sp = WaitGetScenePresence(agentID); | 2898 | |
2755 | if (sp != null) | 2899 | if (sp != null) |
2756 | { | ||
2757 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2758 | |||
2759 | sp.ControllingClient.Close(); | 2900 | sp.ControllingClient.Close(); |
2760 | } | 2901 | |
2761 | else | ||
2762 | { | ||
2763 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2764 | } | ||
2765 | // BANG! SLASH! | 2902 | // BANG! SLASH! |
2766 | m_authenticateHandler.RemoveCircuit(agentID); | 2903 | m_authenticateHandler.RemoveCircuit(agentID); |
2767 | 2904 | ||
@@ -2806,6 +2943,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2806 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2943 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2807 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2944 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2808 | 2945 | ||
2946 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2947 | |||
2809 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2948 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2810 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2949 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2811 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2950 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2862,6 +3001,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2862 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3001 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2863 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3002 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2864 | client.OnCopyInventoryItem += CopyInventoryItem; | 3003 | client.OnCopyInventoryItem += CopyInventoryItem; |
3004 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2865 | client.OnMoveInventoryItem += MoveInventoryItem; | 3005 | client.OnMoveInventoryItem += MoveInventoryItem; |
2866 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3006 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2867 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3007 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2933,6 +3073,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2933 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3073 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2934 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3074 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2935 | 3075 | ||
3076 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3077 | |||
2936 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3078 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2937 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3079 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2938 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3080 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3035,7 +3177,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3035 | /// </summary> | 3177 | /// </summary> |
3036 | /// <param name="agentId">The avatar's Unique ID</param> | 3178 | /// <param name="agentId">The avatar's Unique ID</param> |
3037 | /// <param name="client">The IClientAPI for the client</param> | 3179 | /// <param name="client">The IClientAPI for the client</param> |
3038 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3180 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3039 | { | 3181 | { |
3040 | if (EntityTransferModule != null) | 3182 | if (EntityTransferModule != null) |
3041 | { | 3183 | { |
@@ -3046,6 +3188,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3046 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3188 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3047 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3189 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3048 | } | 3190 | } |
3191 | return false; | ||
3049 | } | 3192 | } |
3050 | 3193 | ||
3051 | /// <summary> | 3194 | /// <summary> |
@@ -3155,6 +3298,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3155 | /// <param name="flags"></param> | 3298 | /// <param name="flags"></param> |
3156 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3299 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3157 | { | 3300 | { |
3301 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3302 | ScenePresence presence; | ||
3303 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3304 | { | ||
3305 | if (presence.Appearance != null) | ||
3306 | { | ||
3307 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3308 | } | ||
3309 | } | ||
3310 | |||
3158 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3311 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3159 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3312 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3160 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3313 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3283,6 +3436,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3283 | avatar.Close(); | 3436 | avatar.Close(); |
3284 | 3437 | ||
3285 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3438 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3439 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3286 | } | 3440 | } |
3287 | catch (Exception e) | 3441 | catch (Exception e) |
3288 | { | 3442 | { |
@@ -3432,13 +3586,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3432 | sp = null; | 3586 | sp = null; |
3433 | } | 3587 | } |
3434 | 3588 | ||
3435 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3436 | 3589 | ||
3437 | //On login test land permisions | 3590 | //On login test land permisions |
3438 | if (vialogin) | 3591 | if (vialogin) |
3439 | { | 3592 | { |
3440 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3593 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3594 | if (cache != null) | ||
3595 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3596 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3441 | { | 3597 | { |
3598 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3442 | return false; | 3599 | return false; |
3443 | } | 3600 | } |
3444 | } | 3601 | } |
@@ -3461,9 +3618,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3461 | 3618 | ||
3462 | try | 3619 | try |
3463 | { | 3620 | { |
3464 | if (!AuthorizeUser(agent, out reason)) | 3621 | // Always check estate if this is a login. Always |
3465 | return false; | 3622 | // check if banned regions are to be blacked out. |
3466 | } catch (Exception e) | 3623 | if (vialogin || (!m_seeIntoBannedRegion)) |
3624 | { | ||
3625 | if (!AuthorizeUser(agent, out reason)) | ||
3626 | return false; | ||
3627 | } | ||
3628 | } | ||
3629 | catch (Exception e) | ||
3467 | { | 3630 | { |
3468 | m_log.ErrorFormat( | 3631 | m_log.ErrorFormat( |
3469 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3632 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3594,6 +3757,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3594 | } | 3757 | } |
3595 | 3758 | ||
3596 | // Honor parcel landing type and position. | 3759 | // Honor parcel landing type and position. |
3760 | /* | ||
3761 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3597 | if (land != null) | 3762 | if (land != null) |
3598 | { | 3763 | { |
3599 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3764 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3601,25 +3766,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3601 | agent.startpos = land.LandData.UserLocation; | 3766 | agent.startpos = land.LandData.UserLocation; |
3602 | } | 3767 | } |
3603 | } | 3768 | } |
3769 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3604 | } | 3770 | } |
3605 | 3771 | ||
3606 | return true; | 3772 | return true; |
3607 | } | 3773 | } |
3608 | 3774 | ||
3609 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3775 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3610 | { | 3776 | { |
3611 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3777 | reason = String.Empty; |
3612 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3778 | if (Permissions.IsGod(agentID)) |
3779 | return true; | ||
3780 | |||
3781 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3782 | if (land == null) | ||
3783 | return false; | ||
3784 | |||
3785 | bool banned = land.IsBannedFromLand(agentID); | ||
3786 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3613 | 3787 | ||
3614 | if (banned || restricted) | 3788 | if (banned || restricted) |
3615 | { | 3789 | { |
3616 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3790 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3617 | if (nearestParcel != null) | 3791 | if (nearestParcel != null) |
3618 | { | 3792 | { |
3619 | //Move agent to nearest allowed | 3793 | //Move agent to nearest allowed |
3620 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3794 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3621 | agent.startpos.X = newPosition.X; | 3795 | posX = newPosition.X; |
3622 | agent.startpos.Y = newPosition.Y; | 3796 | posY = newPosition.Y; |
3623 | } | 3797 | } |
3624 | else | 3798 | else |
3625 | { | 3799 | { |
@@ -3681,7 +3855,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3681 | 3855 | ||
3682 | if (!m_strictAccessControl) return true; | 3856 | if (!m_strictAccessControl) return true; |
3683 | if (Permissions.IsGod(agent.AgentID)) return true; | 3857 | if (Permissions.IsGod(agent.AgentID)) return true; |
3684 | 3858 | ||
3685 | if (AuthorizationService != null) | 3859 | if (AuthorizationService != null) |
3686 | { | 3860 | { |
3687 | if (!AuthorizationService.IsAuthorizedForRegion( | 3861 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3696,7 +3870,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3696 | 3870 | ||
3697 | if (RegionInfo.EstateSettings != null) | 3871 | if (RegionInfo.EstateSettings != null) |
3698 | { | 3872 | { |
3699 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 3873 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3700 | { | 3874 | { |
3701 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3875 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3702 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3876 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3886,6 +4060,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3886 | 4060 | ||
3887 | // XPTO: if this agent is not allowed here as root, always return false | 4061 | // XPTO: if this agent is not allowed here as root, always return false |
3888 | 4062 | ||
4063 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4064 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4065 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4066 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4067 | { | ||
4068 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4069 | return false; | ||
4070 | } | ||
4071 | |||
3889 | // TODO: This check should probably be in QueryAccess(). | 4072 | // TODO: This check should probably be in QueryAccess(). |
3890 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4073 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3891 | if (nearestParcel == null) | 4074 | if (nearestParcel == null) |
@@ -3979,12 +4162,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3979 | return false; | 4162 | return false; |
3980 | } | 4163 | } |
3981 | 4164 | ||
4165 | public bool IncomingCloseAgent(UUID agentID) | ||
4166 | { | ||
4167 | return IncomingCloseAgent(agentID, false); | ||
4168 | } | ||
4169 | |||
4170 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4171 | { | ||
4172 | return IncomingCloseAgent(agentID, true); | ||
4173 | } | ||
4174 | |||
3982 | /// <summary> | 4175 | /// <summary> |
3983 | /// Tell a single agent to disconnect from the region. | 4176 | /// Tell a single agent to disconnect from the region. |
3984 | /// </summary> | 4177 | /// </summary> |
3985 | /// <param name="regionHandle"></param> | ||
3986 | /// <param name="agentID"></param> | 4178 | /// <param name="agentID"></param> |
3987 | public bool IncomingCloseAgent(UUID agentID) | 4179 | /// <param name="childOnly"></param> |
4180 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3988 | { | 4181 | { |
3989 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4182 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3990 | 4183 | ||
@@ -4577,35 +4770,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4577 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 4770 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4578 | } | 4771 | } |
4579 | 4772 | ||
4580 | public int GetHealth() | 4773 | public int GetHealth(out int flags, out string message) |
4581 | { | 4774 | { |
4582 | // Returns: | 4775 | // Returns: |
4583 | // 1 = sim is up and accepting http requests. The heartbeat has | 4776 | // 1 = sim is up and accepting http requests. The heartbeat has |
4584 | // stopped and the sim is probably locked up, but a remote | 4777 | // stopped and the sim is probably locked up, but a remote |
4585 | // admin restart may succeed | 4778 | // admin restart may succeed |
4586 | // | 4779 | // |
4587 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4780 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4588 | // usable for people within and logins _may_ work | 4781 | // usable for people within |
4782 | // | ||
4783 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4784 | // unstable and will not accept new logins | ||
4589 | // | 4785 | // |
4590 | // 3 = We have seen a new user enter within the past 4 minutes | 4786 | // 4 = Sim is up and both packet threads are running. Sim is |
4787 | // likely usable | ||
4788 | // | ||
4789 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4591 | // which can be seen as positive confirmation of sim health | 4790 | // which can be seen as positive confirmation of sim health |
4592 | // | 4791 | // |
4792 | |||
4793 | flags = 0; | ||
4794 | message = String.Empty; | ||
4795 | |||
4796 | CheckHeartbeat(); | ||
4797 | |||
4798 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4799 | { | ||
4800 | // We're still starting | ||
4801 | // 0 means "in startup", it can't happen another way, since | ||
4802 | // to get here, we must be able to accept http connections | ||
4803 | return 0; | ||
4804 | } | ||
4805 | |||
4593 | int health=1; // Start at 1, means we're up | 4806 | int health=1; // Start at 1, means we're up |
4594 | 4807 | ||
4595 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4808 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4596 | health += 1; | 4809 | { |
4810 | health+=1; | ||
4811 | flags |= 1; | ||
4812 | } | ||
4813 | |||
4814 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4815 | { | ||
4816 | health+=1; | ||
4817 | flags |= 2; | ||
4818 | } | ||
4819 | |||
4820 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4821 | { | ||
4822 | health+=1; | ||
4823 | flags |= 4; | ||
4824 | } | ||
4597 | else | 4825 | else |
4826 | { | ||
4827 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4828 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4829 | proc.EnableRaisingEvents=false; | ||
4830 | proc.StartInfo.FileName = "/bin/kill"; | ||
4831 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4832 | proc.Start(); | ||
4833 | proc.WaitForExit(); | ||
4834 | Thread.Sleep(1000); | ||
4835 | Environment.Exit(1); | ||
4836 | } | ||
4837 | |||
4838 | if (flags != 7) | ||
4598 | return health; | 4839 | return health; |
4599 | 4840 | ||
4600 | // A login in the last 4 mins? We can't be doing too badly | 4841 | // A login in the last 4 mins? We can't be doing too badly |
4601 | // | 4842 | // |
4602 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4843 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4603 | health++; | 4844 | health++; |
4604 | else | 4845 | else |
4605 | return health; | 4846 | return health; |
4606 | 4847 | ||
4607 | // CheckHeartbeat(); | ||
4608 | |||
4609 | return health; | 4848 | return health; |
4610 | } | 4849 | } |
4611 | 4850 | ||
@@ -4693,7 +4932,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4693 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4932 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4694 | if (wasUsingPhysics) | 4933 | if (wasUsingPhysics) |
4695 | { | 4934 | { |
4696 | 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 | 4935 | 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 |
4697 | } | 4936 | } |
4698 | } | 4937 | } |
4699 | 4938 | ||
@@ -4792,14 +5031,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4792 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5031 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4793 | } | 5032 | } |
4794 | 5033 | ||
4795 | // private void CheckHeartbeat() | 5034 | private void CheckHeartbeat() |
4796 | // { | 5035 | { |
4797 | // if (m_firstHeartbeat) | 5036 | if (m_firstHeartbeat) |
4798 | // return; | 5037 | return; |
4799 | // | 5038 | |
4800 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5039 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4801 | // StartTimer(); | 5040 | Start(); |
4802 | // } | 5041 | } |
4803 | 5042 | ||
4804 | public override ISceneObject DeserializeObject(string representation) | 5043 | public override ISceneObject DeserializeObject(string representation) |
4805 | { | 5044 | { |
@@ -4811,9 +5050,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4811 | get { return m_allowScriptCrossings; } | 5050 | get { return m_allowScriptCrossings; } |
4812 | } | 5051 | } |
4813 | 5052 | ||
4814 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5053 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5054 | { | ||
5055 | return GetNearestAllowedPosition(avatar, null); | ||
5056 | } | ||
5057 | |||
5058 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4815 | { | 5059 | { |
4816 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5060 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4817 | 5061 | ||
4818 | if (nearestParcel != null) | 5062 | if (nearestParcel != null) |
4819 | { | 5063 | { |
@@ -4822,10 +5066,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4822 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5066 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4823 | if (nearestPoint != null) | 5067 | if (nearestPoint != null) |
4824 | { | 5068 | { |
4825 | // m_log.DebugFormat( | 5069 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4826 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4827 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4828 | |||
4829 | return nearestPoint.Value; | 5070 | return nearestPoint.Value; |
4830 | } | 5071 | } |
4831 | 5072 | ||
@@ -4835,17 +5076,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4835 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5076 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4836 | if (nearestPoint != null) | 5077 | if (nearestPoint != null) |
4837 | { | 5078 | { |
4838 | // m_log.DebugFormat( | 5079 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4839 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4840 | |||
4841 | return nearestPoint.Value; | 5080 | return nearestPoint.Value; |
4842 | } | 5081 | } |
4843 | 5082 | ||
4844 | //Ultimate backup if we have no idea where they are | 5083 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4845 | // m_log.DebugFormat( | 5084 | if (dest != excludeParcel) |
4846 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5085 | { |
5086 | // Ultimate backup if we have no idea where they are and | ||
5087 | // the last allowed position was in another parcel | ||
5088 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5089 | return avatar.lastKnownAllowedPosition; | ||
5090 | } | ||
4847 | 5091 | ||
4848 | return avatar.lastKnownAllowedPosition; | 5092 | // else fall through to region edge |
4849 | } | 5093 | } |
4850 | 5094 | ||
4851 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5095 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4879,13 +5123,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4879 | 5123 | ||
4880 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5124 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4881 | { | 5125 | { |
5126 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5127 | } | ||
5128 | |||
5129 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5130 | { | ||
4882 | List<ILandObject> all = AllParcels(); | 5131 | List<ILandObject> all = AllParcels(); |
4883 | float minParcelDistance = float.MaxValue; | 5132 | float minParcelDistance = float.MaxValue; |
4884 | ILandObject nearestParcel = null; | 5133 | ILandObject nearestParcel = null; |
4885 | 5134 | ||
4886 | foreach (var parcel in all) | 5135 | foreach (var parcel in all) |
4887 | { | 5136 | { |
4888 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5137 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4889 | { | 5138 | { |
4890 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5139 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4891 | if (parcelDistance < minParcelDistance) | 5140 | if (parcelDistance < minParcelDistance) |
@@ -5127,7 +5376,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5127 | mapModule.GenerateMaptile(); | 5376 | mapModule.GenerateMaptile(); |
5128 | } | 5377 | } |
5129 | 5378 | ||
5130 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5379 | // public void CleanDroppedAttachments() |
5380 | // { | ||
5381 | // List<SceneObjectGroup> objectsToDelete = | ||
5382 | // new List<SceneObjectGroup>(); | ||
5383 | // | ||
5384 | // lock (m_cleaningAttachments) | ||
5385 | // { | ||
5386 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5387 | // { | ||
5388 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5389 | // { | ||
5390 | // UUID agentID = grp.OwnerID; | ||
5391 | // if (agentID == UUID.Zero) | ||
5392 | // { | ||
5393 | // objectsToDelete.Add(grp); | ||
5394 | // return; | ||
5395 | // } | ||
5396 | // | ||
5397 | // ScenePresence sp = GetScenePresence(agentID); | ||
5398 | // if (sp == null) | ||
5399 | // { | ||
5400 | // objectsToDelete.Add(grp); | ||
5401 | // return; | ||
5402 | // } | ||
5403 | // } | ||
5404 | // }); | ||
5405 | // } | ||
5406 | // | ||
5407 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5408 | // { | ||
5409 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5410 | // DeleteSceneObject(grp, true); | ||
5411 | // } | ||
5412 | // } | ||
5413 | |||
5414 | public void ThreadAlive(int threadCode) | ||
5415 | { | ||
5416 | switch(threadCode) | ||
5417 | { | ||
5418 | case 1: // Incoming | ||
5419 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5420 | break; | ||
5421 | case 2: // Incoming | ||
5422 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5423 | break; | ||
5424 | } | ||
5425 | } | ||
5426 | |||
5427 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5131 | { | 5428 | { |
5132 | RegenerateMaptile(); | 5429 | RegenerateMaptile(); |
5133 | 5430 | ||
@@ -5155,6 +5452,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5155 | /// <returns></returns> | 5452 | /// <returns></returns> |
5156 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5453 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5157 | { | 5454 | { |
5455 | reason = "You are banned from the region"; | ||
5456 | |||
5158 | if (EntityTransferModule.IsInTransit(agentID)) | 5457 | if (EntityTransferModule.IsInTransit(agentID)) |
5159 | { | 5458 | { |
5160 | reason = "Agent is still in transit from this region"; | 5459 | reason = "Agent is still in transit from this region"; |
@@ -5166,6 +5465,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5166 | return false; | 5465 | return false; |
5167 | } | 5466 | } |
5168 | 5467 | ||
5468 | if (Permissions.IsGod(agentID)) | ||
5469 | { | ||
5470 | reason = String.Empty; | ||
5471 | return true; | ||
5472 | } | ||
5473 | |||
5169 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5474 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5170 | // However, the long term fix is to make sure root agent count is always accurate. | 5475 | // However, the long term fix is to make sure root agent count is always accurate. |
5171 | m_sceneGraph.RecalculateStats(); | 5476 | m_sceneGraph.RecalculateStats(); |
@@ -5186,6 +5491,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5186 | } | 5491 | } |
5187 | } | 5492 | } |
5188 | 5493 | ||
5494 | ScenePresence presence = GetScenePresence(agentID); | ||
5495 | IClientAPI client = null; | ||
5496 | AgentCircuitData aCircuit = null; | ||
5497 | |||
5498 | if (presence != null) | ||
5499 | { | ||
5500 | client = presence.ControllingClient; | ||
5501 | if (client != null) | ||
5502 | aCircuit = client.RequestClientInfo(); | ||
5503 | } | ||
5504 | |||
5505 | // We may be called before there is a presence or a client. | ||
5506 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5507 | if (client == null) | ||
5508 | { | ||
5509 | aCircuit = new AgentCircuitData(); | ||
5510 | aCircuit.AgentID = agentID; | ||
5511 | aCircuit.firstname = String.Empty; | ||
5512 | aCircuit.lastname = String.Empty; | ||
5513 | } | ||
5514 | |||
5515 | try | ||
5516 | { | ||
5517 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5518 | { | ||
5519 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5520 | return false; | ||
5521 | } | ||
5522 | } | ||
5523 | catch (Exception e) | ||
5524 | { | ||
5525 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5526 | return false; | ||
5527 | } | ||
5528 | |||
5189 | if (position == Vector3.Zero) // Teleport | 5529 | if (position == Vector3.Zero) // Teleport |
5190 | { | 5530 | { |
5191 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5531 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5214,13 +5554,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5214 | } | 5554 | } |
5215 | } | 5555 | } |
5216 | } | 5556 | } |
5557 | |||
5558 | float posX = 128.0f; | ||
5559 | float posY = 128.0f; | ||
5560 | |||
5561 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5562 | { | ||
5563 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5564 | return false; | ||
5565 | } | ||
5566 | } | ||
5567 | else // Walking | ||
5568 | { | ||
5569 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5570 | if (land == null) | ||
5571 | return false; | ||
5572 | |||
5573 | bool banned = land.IsBannedFromLand(agentID); | ||
5574 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5575 | |||
5576 | if (banned || restricted) | ||
5577 | return false; | ||
5217 | } | 5578 | } |
5218 | 5579 | ||
5219 | reason = String.Empty; | 5580 | reason = String.Empty; |
5220 | return true; | 5581 | return true; |
5221 | } | 5582 | } |
5222 | 5583 | ||
5223 | /// <summary> | 5584 | public void StartTimerWatchdog() |
5585 | { | ||
5586 | m_timerWatchdog.Interval = 1000; | ||
5587 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5588 | m_timerWatchdog.AutoReset = true; | ||
5589 | m_timerWatchdog.Start(); | ||
5590 | } | ||
5591 | |||
5592 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5593 | { | ||
5594 | CheckHeartbeat(); | ||
5595 | } | ||
5596 | |||
5224 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5597 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5225 | /// autopilot that moves an avatar to a sit target!. | 5598 | /// autopilot that moves an avatar to a sit target!. |
5226 | /// </summary> | 5599 | /// </summary> |