diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 695 |
1 files changed, 534 insertions, 161 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1305d83..85bae9a 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 |
@@ -615,6 +637,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
615 | m_EstateDataService = estateDataService; | 637 | m_EstateDataService = estateDataService; |
616 | m_regionHandle = m_regInfo.RegionHandle; | 638 | m_regionHandle = m_regInfo.RegionHandle; |
617 | m_regionName = m_regInfo.RegionName; | 639 | m_regionName = m_regInfo.RegionName; |
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 |
@@ -1217,7 +1250,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1217 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1250 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1218 | if (m_heartbeatThread != null) | 1251 | if (m_heartbeatThread != null) |
1219 | { | 1252 | { |
1253 | m_hbRestarts++; | ||
1254 | if(m_hbRestarts > 10) | ||
1255 | Environment.Exit(1); | ||
1256 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1257 | |||
1258 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1259 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1260 | //proc.EnableRaisingEvents=false; | ||
1261 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1262 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1263 | //proc.Start(); | ||
1264 | //proc.WaitForExit(); | ||
1265 | //Thread.Sleep(1000); | ||
1266 | //Environment.Exit(1); | ||
1220 | m_heartbeatThread.Abort(); | 1267 | m_heartbeatThread.Abort(); |
1268 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1221 | m_heartbeatThread = null; | 1269 | m_heartbeatThread = null; |
1222 | } | 1270 | } |
1223 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1271 | // 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 | ||
@@ -2053,7 +2126,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2053 | public bool AddRestoredSceneObject( | 2126 | public bool AddRestoredSceneObject( |
2054 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2127 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
2055 | { | 2128 | { |
2056 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2129 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2130 | if (result) | ||
2131 | sceneObject.IsDeleted = false; | ||
2132 | return result; | ||
2057 | } | 2133 | } |
2058 | 2134 | ||
2059 | /// <summary> | 2135 | /// <summary> |
@@ -2145,6 +2221,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2145 | /// </summary> | 2221 | /// </summary> |
2146 | public void DeleteAllSceneObjects() | 2222 | public void DeleteAllSceneObjects() |
2147 | { | 2223 | { |
2224 | DeleteAllSceneObjects(false); | ||
2225 | } | ||
2226 | |||
2227 | /// <summary> | ||
2228 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2229 | /// </summary> | ||
2230 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2231 | { | ||
2232 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2148 | lock (Entities) | 2233 | lock (Entities) |
2149 | { | 2234 | { |
2150 | EntityBase[] entities = Entities.GetEntities(); | 2235 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2153,11 +2238,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2153 | if (e is SceneObjectGroup) | 2238 | if (e is SceneObjectGroup) |
2154 | { | 2239 | { |
2155 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2240 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2156 | if (!sog.IsAttachment) | 2241 | if (sog != null && !sog.IsAttachment) |
2157 | DeleteSceneObject((SceneObjectGroup)e, false); | 2242 | { |
2243 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2244 | { | ||
2245 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2246 | } | ||
2247 | else | ||
2248 | { | ||
2249 | toReturn.Add((SceneObjectGroup)e); | ||
2250 | } | ||
2251 | } | ||
2158 | } | 2252 | } |
2159 | } | 2253 | } |
2160 | } | 2254 | } |
2255 | if (toReturn.Count > 0) | ||
2256 | { | ||
2257 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2258 | } | ||
2161 | } | 2259 | } |
2162 | 2260 | ||
2163 | /// <summary> | 2261 | /// <summary> |
@@ -2192,6 +2290,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2192 | } | 2290 | } |
2193 | 2291 | ||
2194 | group.DeleteGroupFromScene(silent); | 2292 | group.DeleteGroupFromScene(silent); |
2293 | if (!silent) | ||
2294 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2195 | 2295 | ||
2196 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2296 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2197 | } | 2297 | } |
@@ -2481,6 +2581,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2481 | 2581 | ||
2482 | if (newPosition != Vector3.Zero) | 2582 | if (newPosition != Vector3.Zero) |
2483 | newObject.RootPart.GroupPosition = newPosition; | 2583 | newObject.RootPart.GroupPosition = newPosition; |
2584 | if (newObject.RootPart.KeyframeMotion != null) | ||
2585 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2484 | 2586 | ||
2485 | if (!AddSceneObject(newObject)) | 2587 | if (!AddSceneObject(newObject)) |
2486 | { | 2588 | { |
@@ -2549,10 +2651,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2549 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2651 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2550 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2652 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2551 | { | 2653 | { |
2654 | if (sceneObject.OwnerID == UUID.Zero) | ||
2655 | { | ||
2656 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2657 | return false; | ||
2658 | } | ||
2659 | |||
2552 | // If the user is banned, we won't let any of their objects | 2660 | // If the user is banned, we won't let any of their objects |
2553 | // enter. Period. | 2661 | // enter. Period. |
2554 | // | 2662 | // |
2555 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2663 | int flags = GetUserFlags(sceneObject.OwnerID); |
2664 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2556 | { | 2665 | { |
2557 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2666 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2558 | 2667 | ||
@@ -2594,16 +2703,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2594 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2703 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2595 | 2704 | ||
2596 | if (AttachmentsModule != null) | 2705 | if (AttachmentsModule != null) |
2597 | AttachmentsModule.AttachObject(sp, grp, 0, false); | 2706 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); |
2598 | } | 2707 | } |
2599 | else | 2708 | else |
2600 | { | 2709 | { |
2710 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2601 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2711 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2602 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2712 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2603 | } | 2713 | } |
2714 | if (sceneObject.OwnerID == UUID.Zero) | ||
2715 | { | ||
2716 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2717 | return false; | ||
2718 | } | ||
2604 | } | 2719 | } |
2605 | else | 2720 | else |
2606 | { | 2721 | { |
2722 | if (sceneObject.OwnerID == UUID.Zero) | ||
2723 | { | ||
2724 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2725 | return false; | ||
2726 | } | ||
2607 | AddRestoredSceneObject(sceneObject, true, false); | 2727 | AddRestoredSceneObject(sceneObject, true, false); |
2608 | 2728 | ||
2609 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2729 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2632,6 +2752,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2632 | return 2; // StateSource.PrimCrossing | 2752 | return 2; // StateSource.PrimCrossing |
2633 | } | 2753 | } |
2634 | 2754 | ||
2755 | public int GetUserFlags(UUID user) | ||
2756 | { | ||
2757 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2758 | /* | ||
2759 | ScenePresence sp; | ||
2760 | if (TryGetScenePresence(user, out sp)) | ||
2761 | { | ||
2762 | return sp.UserFlags; | ||
2763 | } | ||
2764 | else | ||
2765 | { | ||
2766 | */ | ||
2767 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2768 | if (uac == null) | ||
2769 | return 0; | ||
2770 | return uac.UserFlags; | ||
2771 | //} | ||
2772 | } | ||
2635 | #endregion | 2773 | #endregion |
2636 | 2774 | ||
2637 | #region Add/Remove Avatar Methods | 2775 | #region Add/Remove Avatar Methods |
@@ -2645,7 +2783,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2645 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2783 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2646 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2784 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2647 | 2785 | ||
2648 | // CheckHeartbeat(); | 2786 | CheckHeartbeat(); |
2649 | 2787 | ||
2650 | ScenePresence sp = GetScenePresence(client.AgentId); | 2788 | ScenePresence sp = GetScenePresence(client.AgentId); |
2651 | 2789 | ||
@@ -2699,7 +2837,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2699 | 2837 | ||
2700 | EventManager.TriggerOnNewClient(client); | 2838 | EventManager.TriggerOnNewClient(client); |
2701 | if (vialogin) | 2839 | if (vialogin) |
2840 | { | ||
2702 | EventManager.TriggerOnClientLogin(client); | 2841 | EventManager.TriggerOnClientLogin(client); |
2842 | // Send initial parcel data | ||
2843 | Vector3 pos = sp.AbsolutePosition; | ||
2844 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2845 | land.SendLandUpdateToClient(client); | ||
2846 | } | ||
2703 | 2847 | ||
2704 | return sp; | 2848 | return sp; |
2705 | } | 2849 | } |
@@ -2789,19 +2933,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2789 | // and the scene presence and the client, if they exist | 2933 | // and the scene presence and the client, if they exist |
2790 | try | 2934 | try |
2791 | { | 2935 | { |
2792 | // We need to wait for the client to make UDP contact first. | 2936 | ScenePresence sp = GetScenePresence(agentID); |
2793 | // It's the UDP contact that creates the scene presence | 2937 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2794 | ScenePresence sp = WaitGetScenePresence(agentID); | 2938 | |
2795 | if (sp != null) | 2939 | if (sp != null) |
2796 | { | ||
2797 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2798 | |||
2799 | sp.ControllingClient.Close(); | 2940 | sp.ControllingClient.Close(); |
2800 | } | 2941 | |
2801 | else | ||
2802 | { | ||
2803 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2804 | } | ||
2805 | // BANG! SLASH! | 2942 | // BANG! SLASH! |
2806 | m_authenticateHandler.RemoveCircuit(agentID); | 2943 | m_authenticateHandler.RemoveCircuit(agentID); |
2807 | 2944 | ||
@@ -2846,6 +2983,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2846 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2983 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2847 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2984 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2848 | 2985 | ||
2986 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2987 | |||
2849 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2988 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2850 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2989 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2851 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2990 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2902,6 +3041,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2902 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3041 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2903 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3042 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2904 | client.OnCopyInventoryItem += CopyInventoryItem; | 3043 | client.OnCopyInventoryItem += CopyInventoryItem; |
3044 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2905 | client.OnMoveInventoryItem += MoveInventoryItem; | 3045 | client.OnMoveInventoryItem += MoveInventoryItem; |
2906 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3046 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2907 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3047 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2973,6 +3113,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2973 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3113 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2974 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3114 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2975 | 3115 | ||
3116 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3117 | |||
2976 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3118 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2977 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3119 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2978 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3120 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3075,7 +3217,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3075 | /// </summary> | 3217 | /// </summary> |
3076 | /// <param name="agentId">The avatar's Unique ID</param> | 3218 | /// <param name="agentId">The avatar's Unique ID</param> |
3077 | /// <param name="client">The IClientAPI for the client</param> | 3219 | /// <param name="client">The IClientAPI for the client</param> |
3078 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3220 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3079 | { | 3221 | { |
3080 | if (EntityTransferModule != null) | 3222 | if (EntityTransferModule != null) |
3081 | { | 3223 | { |
@@ -3086,6 +3228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3086 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3228 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3087 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3229 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3088 | } | 3230 | } |
3231 | return false; | ||
3089 | } | 3232 | } |
3090 | 3233 | ||
3091 | /// <summary> | 3234 | /// <summary> |
@@ -3195,6 +3338,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3195 | /// <param name="flags"></param> | 3338 | /// <param name="flags"></param> |
3196 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3339 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3197 | { | 3340 | { |
3341 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3342 | ScenePresence presence; | ||
3343 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3344 | { | ||
3345 | if (presence.Appearance != null) | ||
3346 | { | ||
3347 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3348 | } | ||
3349 | } | ||
3350 | |||
3198 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3351 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3199 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3352 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3200 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3353 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3321,6 +3474,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3321 | avatar.Close(); | 3474 | avatar.Close(); |
3322 | 3475 | ||
3323 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3476 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3477 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3324 | } | 3478 | } |
3325 | catch (Exception e) | 3479 | catch (Exception e) |
3326 | { | 3480 | { |
@@ -3470,13 +3624,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3470 | sp = null; | 3624 | sp = null; |
3471 | } | 3625 | } |
3472 | 3626 | ||
3473 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3474 | 3627 | ||
3475 | //On login test land permisions | 3628 | //On login test land permisions |
3476 | if (vialogin) | 3629 | if (vialogin) |
3477 | { | 3630 | { |
3478 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3631 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3632 | if (cache != null) | ||
3633 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3634 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3479 | { | 3635 | { |
3636 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3480 | return false; | 3637 | return false; |
3481 | } | 3638 | } |
3482 | } | 3639 | } |
@@ -3499,9 +3656,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3499 | 3656 | ||
3500 | try | 3657 | try |
3501 | { | 3658 | { |
3502 | if (!AuthorizeUser(agent, out reason)) | 3659 | // Always check estate if this is a login. Always |
3503 | return false; | 3660 | // check if banned regions are to be blacked out. |
3504 | } catch (Exception e) | 3661 | if (vialogin || (!m_seeIntoBannedRegion)) |
3662 | { | ||
3663 | if (!AuthorizeUser(agent, out reason)) | ||
3664 | return false; | ||
3665 | } | ||
3666 | } | ||
3667 | catch (Exception e) | ||
3505 | { | 3668 | { |
3506 | m_log.ErrorFormat( | 3669 | m_log.ErrorFormat( |
3507 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3670 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3632,6 +3795,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3632 | } | 3795 | } |
3633 | 3796 | ||
3634 | // Honor parcel landing type and position. | 3797 | // Honor parcel landing type and position. |
3798 | /* | ||
3799 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3635 | if (land != null) | 3800 | if (land != null) |
3636 | { | 3801 | { |
3637 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3802 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3639,25 +3804,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3639 | agent.startpos = land.LandData.UserLocation; | 3804 | agent.startpos = land.LandData.UserLocation; |
3640 | } | 3805 | } |
3641 | } | 3806 | } |
3807 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3642 | } | 3808 | } |
3643 | 3809 | ||
3644 | return true; | 3810 | return true; |
3645 | } | 3811 | } |
3646 | 3812 | ||
3647 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3813 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3648 | { | 3814 | { |
3649 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3815 | reason = String.Empty; |
3650 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3816 | if (Permissions.IsGod(agentID)) |
3817 | return true; | ||
3818 | |||
3819 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3820 | if (land == null) | ||
3821 | return false; | ||
3822 | |||
3823 | bool banned = land.IsBannedFromLand(agentID); | ||
3824 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3651 | 3825 | ||
3652 | if (banned || restricted) | 3826 | if (banned || restricted) |
3653 | { | 3827 | { |
3654 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3828 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3655 | if (nearestParcel != null) | 3829 | if (nearestParcel != null) |
3656 | { | 3830 | { |
3657 | //Move agent to nearest allowed | 3831 | //Move agent to nearest allowed |
3658 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3832 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3659 | agent.startpos.X = newPosition.X; | 3833 | posX = newPosition.X; |
3660 | agent.startpos.Y = newPosition.Y; | 3834 | posY = newPosition.Y; |
3661 | } | 3835 | } |
3662 | else | 3836 | else |
3663 | { | 3837 | { |
@@ -3719,7 +3893,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3719 | 3893 | ||
3720 | if (!m_strictAccessControl) return true; | 3894 | if (!m_strictAccessControl) return true; |
3721 | if (Permissions.IsGod(agent.AgentID)) return true; | 3895 | if (Permissions.IsGod(agent.AgentID)) return true; |
3722 | 3896 | ||
3723 | if (AuthorizationService != null) | 3897 | if (AuthorizationService != null) |
3724 | { | 3898 | { |
3725 | if (!AuthorizationService.IsAuthorizedForRegion( | 3899 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3734,7 +3908,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3734 | 3908 | ||
3735 | if (m_regInfo.EstateSettings != null) | 3909 | if (m_regInfo.EstateSettings != null) |
3736 | { | 3910 | { |
3737 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3911 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3738 | { | 3912 | { |
3739 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3913 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3740 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3914 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3924,6 +4098,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3924 | 4098 | ||
3925 | // XPTO: if this agent is not allowed here as root, always return false | 4099 | // XPTO: if this agent is not allowed here as root, always return false |
3926 | 4100 | ||
4101 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4102 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4103 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4104 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4105 | { | ||
4106 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4107 | return false; | ||
4108 | } | ||
4109 | |||
3927 | // TODO: This check should probably be in QueryAccess(). | 4110 | // TODO: This check should probably be in QueryAccess(). |
3928 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4111 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3929 | if (nearestParcel == null) | 4112 | if (nearestParcel == null) |
@@ -4017,12 +4200,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4017 | return false; | 4200 | return false; |
4018 | } | 4201 | } |
4019 | 4202 | ||
4203 | public bool IncomingCloseAgent(UUID agentID) | ||
4204 | { | ||
4205 | return IncomingCloseAgent(agentID, false); | ||
4206 | } | ||
4207 | |||
4208 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4209 | { | ||
4210 | return IncomingCloseAgent(agentID, true); | ||
4211 | } | ||
4212 | |||
4020 | /// <summary> | 4213 | /// <summary> |
4021 | /// Tell a single agent to disconnect from the region. | 4214 | /// Tell a single agent to disconnect from the region. |
4022 | /// </summary> | 4215 | /// </summary> |
4023 | /// <param name="regionHandle"></param> | ||
4024 | /// <param name="agentID"></param> | 4216 | /// <param name="agentID"></param> |
4025 | public bool IncomingCloseAgent(UUID agentID) | 4217 | /// <param name="childOnly"></param> |
4218 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
4026 | { | 4219 | { |
4027 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4220 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
4028 | 4221 | ||
@@ -4615,35 +4808,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4615 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4808 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4616 | } | 4809 | } |
4617 | 4810 | ||
4618 | public int GetHealth() | 4811 | public int GetHealth(out int flags, out string message) |
4619 | { | 4812 | { |
4620 | // Returns: | 4813 | // Returns: |
4621 | // 1 = sim is up and accepting http requests. The heartbeat has | 4814 | // 1 = sim is up and accepting http requests. The heartbeat has |
4622 | // stopped and the sim is probably locked up, but a remote | 4815 | // stopped and the sim is probably locked up, but a remote |
4623 | // admin restart may succeed | 4816 | // admin restart may succeed |
4624 | // | 4817 | // |
4625 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4818 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4626 | // usable for people within and logins _may_ work | 4819 | // usable for people within |
4820 | // | ||
4821 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4822 | // unstable and will not accept new logins | ||
4627 | // | 4823 | // |
4628 | // 3 = We have seen a new user enter within the past 4 minutes | 4824 | // 4 = Sim is up and both packet threads are running. Sim is |
4825 | // likely usable | ||
4826 | // | ||
4827 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4629 | // which can be seen as positive confirmation of sim health | 4828 | // which can be seen as positive confirmation of sim health |
4630 | // | 4829 | // |
4830 | |||
4831 | flags = 0; | ||
4832 | message = String.Empty; | ||
4833 | |||
4834 | CheckHeartbeat(); | ||
4835 | |||
4836 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4837 | { | ||
4838 | // We're still starting | ||
4839 | // 0 means "in startup", it can't happen another way, since | ||
4840 | // to get here, we must be able to accept http connections | ||
4841 | return 0; | ||
4842 | } | ||
4843 | |||
4631 | int health=1; // Start at 1, means we're up | 4844 | int health=1; // Start at 1, means we're up |
4632 | 4845 | ||
4633 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4846 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4634 | health += 1; | 4847 | { |
4848 | health+=1; | ||
4849 | flags |= 1; | ||
4850 | } | ||
4851 | |||
4852 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4853 | { | ||
4854 | health+=1; | ||
4855 | flags |= 2; | ||
4856 | } | ||
4857 | |||
4858 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4859 | { | ||
4860 | health+=1; | ||
4861 | flags |= 4; | ||
4862 | } | ||
4635 | else | 4863 | else |
4864 | { | ||
4865 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4866 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4867 | proc.EnableRaisingEvents=false; | ||
4868 | proc.StartInfo.FileName = "/bin/kill"; | ||
4869 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4870 | proc.Start(); | ||
4871 | proc.WaitForExit(); | ||
4872 | Thread.Sleep(1000); | ||
4873 | Environment.Exit(1); | ||
4874 | } | ||
4875 | |||
4876 | if (flags != 7) | ||
4636 | return health; | 4877 | return health; |
4637 | 4878 | ||
4638 | // A login in the last 4 mins? We can't be doing too badly | 4879 | // A login in the last 4 mins? We can't be doing too badly |
4639 | // | 4880 | // |
4640 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4881 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4641 | health++; | 4882 | health++; |
4642 | else | 4883 | else |
4643 | return health; | 4884 | return health; |
4644 | 4885 | ||
4645 | // CheckHeartbeat(); | ||
4646 | |||
4647 | return health; | 4886 | return health; |
4648 | } | 4887 | } |
4649 | 4888 | ||
@@ -4731,7 +4970,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4731 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4970 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4732 | if (wasUsingPhysics) | 4971 | if (wasUsingPhysics) |
4733 | { | 4972 | { |
4734 | 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 | 4973 | 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 |
4735 | } | 4974 | } |
4736 | } | 4975 | } |
4737 | 4976 | ||
@@ -4830,14 +5069,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4830 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5069 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4831 | } | 5070 | } |
4832 | 5071 | ||
4833 | // private void CheckHeartbeat() | 5072 | private void CheckHeartbeat() |
4834 | // { | 5073 | { |
4835 | // if (m_firstHeartbeat) | 5074 | if (m_firstHeartbeat) |
4836 | // return; | 5075 | return; |
4837 | // | 5076 | |
4838 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5077 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4839 | // StartTimer(); | 5078 | Start(); |
4840 | // } | 5079 | } |
4841 | 5080 | ||
4842 | public override ISceneObject DeserializeObject(string representation) | 5081 | public override ISceneObject DeserializeObject(string representation) |
4843 | { | 5082 | { |
@@ -4849,9 +5088,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4849 | get { return m_allowScriptCrossings; } | 5088 | get { return m_allowScriptCrossings; } |
4850 | } | 5089 | } |
4851 | 5090 | ||
4852 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5091 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5092 | { | ||
5093 | return GetNearestAllowedPosition(avatar, null); | ||
5094 | } | ||
5095 | |||
5096 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4853 | { | 5097 | { |
4854 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5098 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4855 | 5099 | ||
4856 | if (nearestParcel != null) | 5100 | if (nearestParcel != null) |
4857 | { | 5101 | { |
@@ -4860,10 +5104,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4860 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5104 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4861 | if (nearestPoint != null) | 5105 | if (nearestPoint != null) |
4862 | { | 5106 | { |
4863 | // m_log.DebugFormat( | 5107 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4864 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4865 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4866 | |||
4867 | return nearestPoint.Value; | 5108 | return nearestPoint.Value; |
4868 | } | 5109 | } |
4869 | 5110 | ||
@@ -4873,17 +5114,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4873 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5114 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4874 | if (nearestPoint != null) | 5115 | if (nearestPoint != null) |
4875 | { | 5116 | { |
4876 | // m_log.DebugFormat( | 5117 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4877 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4878 | |||
4879 | return nearestPoint.Value; | 5118 | return nearestPoint.Value; |
4880 | } | 5119 | } |
4881 | 5120 | ||
4882 | //Ultimate backup if we have no idea where they are | 5121 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4883 | // m_log.DebugFormat( | 5122 | if (dest != excludeParcel) |
4884 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5123 | { |
5124 | // Ultimate backup if we have no idea where they are and | ||
5125 | // the last allowed position was in another parcel | ||
5126 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5127 | return avatar.lastKnownAllowedPosition; | ||
5128 | } | ||
4885 | 5129 | ||
4886 | return avatar.lastKnownAllowedPosition; | 5130 | // else fall through to region edge |
4887 | } | 5131 | } |
4888 | 5132 | ||
4889 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5133 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4917,13 +5161,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4917 | 5161 | ||
4918 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5162 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4919 | { | 5163 | { |
5164 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5165 | } | ||
5166 | |||
5167 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5168 | { | ||
4920 | List<ILandObject> all = AllParcels(); | 5169 | List<ILandObject> all = AllParcels(); |
4921 | float minParcelDistance = float.MaxValue; | 5170 | float minParcelDistance = float.MaxValue; |
4922 | ILandObject nearestParcel = null; | 5171 | ILandObject nearestParcel = null; |
4923 | 5172 | ||
4924 | foreach (var parcel in all) | 5173 | foreach (var parcel in all) |
4925 | { | 5174 | { |
4926 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5175 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4927 | { | 5176 | { |
4928 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5177 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4929 | if (parcelDistance < minParcelDistance) | 5178 | if (parcelDistance < minParcelDistance) |
@@ -5165,7 +5414,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5165 | mapModule.GenerateMaptile(); | 5414 | mapModule.GenerateMaptile(); |
5166 | } | 5415 | } |
5167 | 5416 | ||
5168 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5417 | // public void CleanDroppedAttachments() |
5418 | // { | ||
5419 | // List<SceneObjectGroup> objectsToDelete = | ||
5420 | // new List<SceneObjectGroup>(); | ||
5421 | // | ||
5422 | // lock (m_cleaningAttachments) | ||
5423 | // { | ||
5424 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5425 | // { | ||
5426 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5427 | // { | ||
5428 | // UUID agentID = grp.OwnerID; | ||
5429 | // if (agentID == UUID.Zero) | ||
5430 | // { | ||
5431 | // objectsToDelete.Add(grp); | ||
5432 | // return; | ||
5433 | // } | ||
5434 | // | ||
5435 | // ScenePresence sp = GetScenePresence(agentID); | ||
5436 | // if (sp == null) | ||
5437 | // { | ||
5438 | // objectsToDelete.Add(grp); | ||
5439 | // return; | ||
5440 | // } | ||
5441 | // } | ||
5442 | // }); | ||
5443 | // } | ||
5444 | // | ||
5445 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5446 | // { | ||
5447 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5448 | // DeleteSceneObject(grp, true); | ||
5449 | // } | ||
5450 | // } | ||
5451 | |||
5452 | public void ThreadAlive(int threadCode) | ||
5453 | { | ||
5454 | switch(threadCode) | ||
5455 | { | ||
5456 | case 1: // Incoming | ||
5457 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5458 | break; | ||
5459 | case 2: // Incoming | ||
5460 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5461 | break; | ||
5462 | } | ||
5463 | } | ||
5464 | |||
5465 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5169 | { | 5466 | { |
5170 | RegenerateMaptile(); | 5467 | RegenerateMaptile(); |
5171 | 5468 | ||
@@ -5193,6 +5490,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5193 | /// <returns></returns> | 5490 | /// <returns></returns> |
5194 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5491 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5195 | { | 5492 | { |
5493 | reason = "You are banned from the region"; | ||
5494 | |||
5196 | if (EntityTransferModule.IsInTransit(agentID)) | 5495 | if (EntityTransferModule.IsInTransit(agentID)) |
5197 | { | 5496 | { |
5198 | reason = "Agent is still in transit from this region"; | 5497 | reason = "Agent is still in transit from this region"; |
@@ -5204,6 +5503,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5204 | return false; | 5503 | return false; |
5205 | } | 5504 | } |
5206 | 5505 | ||
5506 | if (Permissions.IsGod(agentID)) | ||
5507 | { | ||
5508 | reason = String.Empty; | ||
5509 | return true; | ||
5510 | } | ||
5511 | |||
5207 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5512 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5208 | // However, the long term fix is to make sure root agent count is always accurate. | 5513 | // However, the long term fix is to make sure root agent count is always accurate. |
5209 | m_sceneGraph.RecalculateStats(); | 5514 | m_sceneGraph.RecalculateStats(); |
@@ -5224,6 +5529,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5224 | } | 5529 | } |
5225 | } | 5530 | } |
5226 | 5531 | ||
5532 | ScenePresence presence = GetScenePresence(agentID); | ||
5533 | IClientAPI client = null; | ||
5534 | AgentCircuitData aCircuit = null; | ||
5535 | |||
5536 | if (presence != null) | ||
5537 | { | ||
5538 | client = presence.ControllingClient; | ||
5539 | if (client != null) | ||
5540 | aCircuit = client.RequestClientInfo(); | ||
5541 | } | ||
5542 | |||
5543 | // We may be called before there is a presence or a client. | ||
5544 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5545 | if (client == null) | ||
5546 | { | ||
5547 | aCircuit = new AgentCircuitData(); | ||
5548 | aCircuit.AgentID = agentID; | ||
5549 | aCircuit.firstname = String.Empty; | ||
5550 | aCircuit.lastname = String.Empty; | ||
5551 | } | ||
5552 | |||
5553 | try | ||
5554 | { | ||
5555 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5556 | { | ||
5557 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5558 | return false; | ||
5559 | } | ||
5560 | } | ||
5561 | catch (Exception e) | ||
5562 | { | ||
5563 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5564 | return false; | ||
5565 | } | ||
5566 | |||
5227 | if (position == Vector3.Zero) // Teleport | 5567 | if (position == Vector3.Zero) // Teleport |
5228 | { | 5568 | { |
5229 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5569 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5252,13 +5592,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5252 | } | 5592 | } |
5253 | } | 5593 | } |
5254 | } | 5594 | } |
5595 | |||
5596 | float posX = 128.0f; | ||
5597 | float posY = 128.0f; | ||
5598 | |||
5599 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5600 | { | ||
5601 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5602 | return false; | ||
5603 | } | ||
5604 | } | ||
5605 | else // Walking | ||
5606 | { | ||
5607 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5608 | if (land == null) | ||
5609 | return false; | ||
5610 | |||
5611 | bool banned = land.IsBannedFromLand(agentID); | ||
5612 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5613 | |||
5614 | if (banned || restricted) | ||
5615 | return false; | ||
5255 | } | 5616 | } |
5256 | 5617 | ||
5257 | reason = String.Empty; | 5618 | reason = String.Empty; |
5258 | return true; | 5619 | return true; |
5259 | } | 5620 | } |
5260 | 5621 | ||
5261 | /// <summary> | 5622 | public void StartTimerWatchdog() |
5623 | { | ||
5624 | m_timerWatchdog.Interval = 1000; | ||
5625 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5626 | m_timerWatchdog.AutoReset = true; | ||
5627 | m_timerWatchdog.Start(); | ||
5628 | } | ||
5629 | |||
5630 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5631 | { | ||
5632 | CheckHeartbeat(); | ||
5633 | } | ||
5634 | |||
5262 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5635 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5263 | /// autopilot that moves an avatar to a sit target!. | 5636 | /// autopilot that moves an avatar to a sit target!. |
5264 | /// </summary> | 5637 | /// </summary> |