diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 733 |
1 files changed, 558 insertions, 175 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 25223b9..eae8b8e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -127,6 +127,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
127 | // TODO: need to figure out how allow client agents but deny | 127 | // TODO: need to figure out how allow client agents but deny |
128 | // root agents when ACL denies access to root agent | 128 | // root agents when ACL denies access to root agent |
129 | public bool m_strictAccessControl = true; | 129 | public bool m_strictAccessControl = true; |
130 | public bool m_seeIntoBannedRegion = false; | ||
130 | public int MaxUndoCount = 5; | 131 | public int MaxUndoCount = 5; |
131 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 132 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
132 | public bool LoginLock = false; | 133 | public bool LoginLock = false; |
@@ -142,12 +143,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
142 | 143 | ||
143 | protected int m_splitRegionID; | 144 | protected int m_splitRegionID; |
144 | protected Timer m_restartWaitTimer = new Timer(); | 145 | protected Timer m_restartWaitTimer = new Timer(); |
146 | protected Timer m_timerWatchdog = new Timer(); | ||
145 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 147 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
146 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 148 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
147 | protected string m_simulatorVersion = "OpenSimulator Server"; | 149 | protected string m_simulatorVersion = "OpenSimulator Server"; |
148 | protected ModuleLoader m_moduleLoader; | 150 | protected ModuleLoader m_moduleLoader; |
149 | protected AgentCircuitManager m_authenticateHandler; | 151 | protected AgentCircuitManager m_authenticateHandler; |
150 | protected SceneCommunicationService m_sceneGridService; | 152 | protected SceneCommunicationService m_sceneGridService; |
153 | protected ISnmpModule m_snmpService = null; | ||
151 | 154 | ||
152 | protected ISimulationDataService m_SimulationDataService; | 155 | protected ISimulationDataService m_SimulationDataService; |
153 | protected IEstateDataService m_EstateDataService; | 156 | protected IEstateDataService m_EstateDataService; |
@@ -209,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
209 | private int m_update_events = 1; | 212 | private int m_update_events = 1; |
210 | private int m_update_backup = 200; | 213 | private int m_update_backup = 200; |
211 | private int m_update_terrain = 50; | 214 | private int m_update_terrain = 50; |
212 | // private int m_update_land = 1; | 215 | private int m_update_land = 10; |
213 | private int m_update_coarse_locations = 50; | 216 | private int m_update_coarse_locations = 50; |
214 | 217 | ||
215 | private int agentMS; | 218 | private int agentMS; |
@@ -229,6 +232,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
229 | /// </summary> | 232 | /// </summary> |
230 | private int m_lastFrameTick; | 233 | private int m_lastFrameTick; |
231 | 234 | ||
235 | public bool CombineRegions = false; | ||
232 | /// <summary> | 236 | /// <summary> |
233 | /// Tick at which the last maintenance run occurred. | 237 | /// Tick at which the last maintenance run occurred. |
234 | /// </summary> | 238 | /// </summary> |
@@ -259,6 +263,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | /// </summary> | 263 | /// </summary> |
260 | private int m_LastLogin; | 264 | private int m_LastLogin; |
261 | 265 | ||
266 | private int m_lastIncoming; | ||
267 | private int m_lastOutgoing; | ||
268 | private int m_hbRestarts = 0; | ||
269 | |||
270 | |||
262 | /// <summary> | 271 | /// <summary> |
263 | /// Thread that runs the scene loop. | 272 | /// Thread that runs the scene loop. |
264 | /// </summary> | 273 | /// </summary> |
@@ -274,7 +283,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
274 | private volatile bool m_shuttingDown; | 283 | private volatile bool m_shuttingDown; |
275 | 284 | ||
276 | // private int m_lastUpdate; | 285 | // private int m_lastUpdate; |
277 | // private bool m_firstHeartbeat = true; | 286 | private bool m_firstHeartbeat = true; |
278 | 287 | ||
279 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 288 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
280 | private bool m_reprioritizationEnabled = true; | 289 | private bool m_reprioritizationEnabled = true; |
@@ -319,6 +328,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
319 | get { return m_sceneGridService; } | 328 | get { return m_sceneGridService; } |
320 | } | 329 | } |
321 | 330 | ||
331 | public ISnmpModule SnmpService | ||
332 | { | ||
333 | get | ||
334 | { | ||
335 | if (m_snmpService == null) | ||
336 | { | ||
337 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
338 | } | ||
339 | |||
340 | return m_snmpService; | ||
341 | } | ||
342 | } | ||
343 | |||
322 | public ISimulationDataService SimulationDataService | 344 | public ISimulationDataService SimulationDataService |
323 | { | 345 | { |
324 | get | 346 | get |
@@ -617,7 +639,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
617 | m_sceneGridService = sceneGridService; | 639 | m_sceneGridService = sceneGridService; |
618 | m_SimulationDataService = simDataService; | 640 | m_SimulationDataService = simDataService; |
619 | m_EstateDataService = estateDataService; | 641 | m_EstateDataService = estateDataService; |
620 | m_regionHandle = RegionInfo.RegionHandle; | 642 | m_regionHandle = m_regInfo.RegionHandle; |
643 | m_lastIncoming = 0; | ||
644 | m_lastOutgoing = 0; | ||
621 | 645 | ||
622 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 646 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
623 | m_asyncSceneObjectDeleter.Enabled = true; | 647 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -698,120 +722,129 @@ namespace OpenSim.Region.Framework.Scenes | |||
698 | 722 | ||
699 | // Region config overrides global config | 723 | // Region config overrides global config |
700 | // | 724 | // |
701 | if (m_config.Configs["Startup"] != null) | 725 | try |
702 | { | 726 | { |
703 | IConfig startupConfig = m_config.Configs["Startup"]; | 727 | if (m_config.Configs["Startup"] != null) |
704 | |||
705 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | ||
706 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | ||
707 | if (!m_useBackup) | ||
708 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | ||
709 | |||
710 | //Animation states | ||
711 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
712 | |||
713 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
714 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
715 | |||
716 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | ||
717 | if (RegionInfo.NonphysPrimMax > 0) | ||
718 | { | ||
719 | m_maxNonphys = RegionInfo.NonphysPrimMax; | ||
720 | } | ||
721 | |||
722 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | ||
723 | |||
724 | if (RegionInfo.PhysPrimMax > 0) | ||
725 | { | 728 | { |
726 | m_maxPhys = RegionInfo.PhysPrimMax; | 729 | IConfig startupConfig = m_config.Configs["Startup"]; |
727 | } | ||
728 | 730 | ||
729 | // Here, if clamping is requested in either global or | 731 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
730 | // local config, it will be used | 732 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
731 | // | 733 | if (!m_useBackup) |
732 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | 734 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
733 | if (RegionInfo.ClampPrimSize) | 735 | |
734 | { | 736 | //Animation states |
735 | m_clampPrimSize = true; | 737 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
736 | } | ||
737 | 738 | ||
738 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | 739 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
739 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 740 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
740 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | ||
741 | m_dontPersistBefore = | ||
742 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | ||
743 | m_dontPersistBefore *= 10000000; | ||
744 | m_persistAfter = | ||
745 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
746 | m_persistAfter *= 10000000; | ||
747 | 741 | ||
748 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 742 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
743 | if (RegionInfo.NonphysPrimMax > 0) | ||
744 | { | ||
745 | m_maxNonphys = RegionInfo.NonphysPrimMax; | ||
746 | } | ||
749 | 747 | ||
750 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | 748 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
751 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
752 | 749 | ||
753 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 750 | if (RegionInfo.PhysPrimMax > 0) |
754 | if (packetConfig != null) | 751 | { |
755 | { | 752 | m_maxPhys = RegionInfo.PhysPrimMax; |
756 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | 753 | } |
757 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | ||
758 | } | ||
759 | 754 | ||
760 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 755 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); |
756 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
761 | 757 | ||
762 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 758 | // Here, if clamping is requested in either global or |
763 | if (m_generateMaptiles) | 759 | // local config, it will be used |
764 | { | 760 | // |
765 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | 761 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); |
766 | if (maptileRefresh != 0) | 762 | if (RegionInfo.ClampPrimSize) |
767 | { | 763 | { |
768 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 764 | m_clampPrimSize = true; |
769 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
770 | m_mapGenerationTimer.AutoReset = true; | ||
771 | m_mapGenerationTimer.Start(); | ||
772 | } | 765 | } |
773 | } | ||
774 | else | ||
775 | { | ||
776 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
777 | UUID tileID; | ||
778 | 766 | ||
779 | if (UUID.TryParse(tile, out tileID)) | 767 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
768 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | ||
769 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | ||
770 | m_dontPersistBefore = | ||
771 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | ||
772 | m_dontPersistBefore *= 10000000; | ||
773 | m_persistAfter = | ||
774 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
775 | m_persistAfter *= 10000000; | ||
776 | |||
777 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | ||
778 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
779 | |||
780 | IConfig packetConfig = m_config.Configs["PacketPool"]; | ||
781 | if (packetConfig != null) | ||
780 | { | 782 | { |
781 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 783 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
784 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | ||
782 | } | 785 | } |
783 | } | ||
784 | 786 | ||
785 | string grant = startupConfig.GetString("AllowedViewerList", String.Empty); | 787 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
786 | if (grant.Length > 0) | 788 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); |
787 | { | 789 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); |
788 | foreach (string viewer in grant.Split(',')) | 790 | |
791 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | ||
792 | if (m_generateMaptiles) | ||
789 | { | 793 | { |
790 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 794 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
795 | if (maptileRefresh != 0) | ||
796 | { | ||
797 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | ||
798 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
799 | m_mapGenerationTimer.AutoReset = true; | ||
800 | m_mapGenerationTimer.Start(); | ||
801 | } | ||
791 | } | 802 | } |
792 | } | 803 | else |
804 | { | ||
805 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
806 | UUID tileID; | ||
793 | 807 | ||
794 | grant = startupConfig.GetString("BannedViewerList", String.Empty); | 808 | if (UUID.TryParse(tile, out tileID)) |
795 | if (grant.Length > 0) | 809 | { |
796 | { | 810 | RegionInfo.RegionSettings.TerrainImageID = tileID; |
797 | foreach (string viewer in grant.Split(',')) | 811 | } |
812 | } | ||
813 | |||
814 | string grant = startupConfig.GetString("AllowedViewerList", String.Empty); | ||
815 | if (grant.Length > 0) | ||
798 | { | 816 | { |
799 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 817 | foreach (string viewer in grant.Split(',')) |
818 | { | ||
819 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | ||
820 | } | ||
800 | } | 821 | } |
801 | } | ||
802 | 822 | ||
803 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 823 | grant = startupConfig.GetString("BannedViewerList", String.Empty); |
804 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 824 | if (grant.Length > 0) |
805 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 825 | { |
806 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 826 | foreach (string viewer in grant.Split(',')) |
807 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 827 | { |
808 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | 828 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
809 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | 829 | } |
810 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | 830 | } |
811 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
812 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
813 | 831 | ||
814 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | 832 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
833 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | ||
834 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | ||
835 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | ||
836 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | ||
837 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
838 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
839 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
840 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
841 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
842 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | ||
843 | } | ||
844 | } | ||
845 | catch (Exception e) | ||
846 | { | ||
847 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
815 | } | 848 | } |
816 | 849 | ||
817 | #endregion Region Config | 850 | #endregion Region Config |
@@ -1237,7 +1270,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1237 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1270 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1238 | if (m_heartbeatThread != null) | 1271 | if (m_heartbeatThread != null) |
1239 | { | 1272 | { |
1273 | m_hbRestarts++; | ||
1274 | if(m_hbRestarts > 10) | ||
1275 | Environment.Exit(1); | ||
1276 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1277 | |||
1278 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1279 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1280 | //proc.EnableRaisingEvents=false; | ||
1281 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1282 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1283 | //proc.Start(); | ||
1284 | //proc.WaitForExit(); | ||
1285 | //Thread.Sleep(1000); | ||
1286 | //Environment.Exit(1); | ||
1240 | m_heartbeatThread.Abort(); | 1287 | m_heartbeatThread.Abort(); |
1288 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1241 | m_heartbeatThread = null; | 1289 | m_heartbeatThread = null; |
1242 | } | 1290 | } |
1243 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1291 | // m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1528,6 +1576,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1528 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1576 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); |
1529 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1577 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1530 | 1578 | ||
1579 | m_firstHeartbeat = false; | ||
1580 | |||
1531 | if (tmpMS > 0) | 1581 | if (tmpMS > 0) |
1532 | { | 1582 | { |
1533 | Thread.Sleep(tmpMS); | 1583 | Thread.Sleep(tmpMS); |
@@ -1578,9 +1628,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1578 | 1628 | ||
1579 | private void CheckAtTargets() | 1629 | private void CheckAtTargets() |
1580 | { | 1630 | { |
1581 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1631 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1582 | lock (m_groupsWithTargets) | 1632 | lock (m_groupsWithTargets) |
1583 | objs = m_groupsWithTargets.Values; | 1633 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1584 | 1634 | ||
1585 | foreach (SceneObjectGroup entry in objs) | 1635 | foreach (SceneObjectGroup entry in objs) |
1586 | entry.checkAtTargets(); | 1636 | entry.checkAtTargets(); |
@@ -1661,7 +1711,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1661 | msg.fromAgentName = "Server"; | 1711 | msg.fromAgentName = "Server"; |
1662 | msg.dialog = (byte)19; // Object msg | 1712 | msg.dialog = (byte)19; // Object msg |
1663 | msg.fromGroup = false; | 1713 | msg.fromGroup = false; |
1664 | msg.offline = (byte)0; | 1714 | msg.offline = (byte)1; |
1665 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1715 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1666 | msg.Position = Vector3.Zero; | 1716 | msg.Position = Vector3.Zero; |
1667 | msg.RegionID = RegionInfo.RegionID.Guid; | 1717 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1883,6 +1933,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1883 | EventManager.TriggerPrimsLoaded(this); | 1933 | EventManager.TriggerPrimsLoaded(this); |
1884 | } | 1934 | } |
1885 | 1935 | ||
1936 | public bool SuportsRayCastFiltered() | ||
1937 | { | ||
1938 | if (PhysicsScene == null) | ||
1939 | return false; | ||
1940 | return PhysicsScene.SuportsRaycastWorldFiltered(); | ||
1941 | } | ||
1942 | |||
1943 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | ||
1944 | { | ||
1945 | if (PhysicsScene == null) | ||
1946 | return null; | ||
1947 | return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); | ||
1948 | } | ||
1886 | 1949 | ||
1887 | /// <summary> | 1950 | /// <summary> |
1888 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. | 1951 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. |
@@ -1899,14 +1962,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1899 | /// <returns></returns> | 1962 | /// <returns></returns> |
1900 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1963 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1901 | { | 1964 | { |
1965 | |||
1966 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1967 | Vector3 wpos = Vector3.Zero; | ||
1968 | // Check for water surface intersection from above | ||
1969 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1970 | { | ||
1971 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1972 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1973 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1974 | wpos.Z = wheight; | ||
1975 | } | ||
1976 | |||
1902 | Vector3 pos = Vector3.Zero; | 1977 | Vector3 pos = Vector3.Zero; |
1903 | if (RayEndIsIntersection == (byte)1) | 1978 | if (RayEndIsIntersection == (byte)1) |
1904 | { | 1979 | { |
1905 | pos = RayEnd; | 1980 | pos = RayEnd; |
1906 | return pos; | ||
1907 | } | 1981 | } |
1908 | 1982 | else if (RayTargetID != UUID.Zero) | |
1909 | if (RayTargetID != UUID.Zero) | ||
1910 | { | 1983 | { |
1911 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1984 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1912 | 1985 | ||
@@ -1928,7 +2001,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1928 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2001 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1929 | 2002 | ||
1930 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2003 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1931 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2004 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1932 | float ScaleOffset = 0.5f; | 2005 | float ScaleOffset = 0.5f; |
1933 | 2006 | ||
1934 | // If we hit something | 2007 | // If we hit something |
@@ -1951,13 +2024,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1951 | //pos.Z -= 0.25F; | 2024 | //pos.Z -= 0.25F; |
1952 | 2025 | ||
1953 | } | 2026 | } |
1954 | |||
1955 | return pos; | ||
1956 | } | 2027 | } |
1957 | else | 2028 | else |
1958 | { | 2029 | { |
1959 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2030 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1960 | |||
1961 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2031 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1962 | 2032 | ||
1963 | // Un-comment the following line to print the raytrace results to the console. | 2033 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1966,13 +2036,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1966 | if (ei.HitTF) | 2036 | if (ei.HitTF) |
1967 | { | 2037 | { |
1968 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2038 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1969 | } else | 2039 | } |
2040 | else | ||
1970 | { | 2041 | { |
1971 | // fall back to our stupid functionality | 2042 | // fall back to our stupid functionality |
1972 | pos = RayEnd; | 2043 | pos = RayEnd; |
1973 | } | 2044 | } |
1974 | |||
1975 | return pos; | ||
1976 | } | 2045 | } |
1977 | } | 2046 | } |
1978 | else | 2047 | else |
@@ -1983,8 +2052,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1983 | //increase height so its above the ground. | 2052 | //increase height so its above the ground. |
1984 | //should be getting the normal of the ground at the rez point and using that? | 2053 | //should be getting the normal of the ground at the rez point and using that? |
1985 | pos.Z += scale.Z / 2f; | 2054 | pos.Z += scale.Z / 2f; |
1986 | return pos; | 2055 | // return pos; |
1987 | } | 2056 | } |
2057 | |||
2058 | // check against posible water intercept | ||
2059 | if (wpos.Z > pos.Z) pos = wpos; | ||
2060 | return pos; | ||
1988 | } | 2061 | } |
1989 | 2062 | ||
1990 | 2063 | ||
@@ -2073,7 +2146,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2073 | public bool AddRestoredSceneObject( | 2146 | public bool AddRestoredSceneObject( |
2074 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2147 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
2075 | { | 2148 | { |
2076 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2149 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2150 | if (result) | ||
2151 | sceneObject.IsDeleted = false; | ||
2152 | return result; | ||
2077 | } | 2153 | } |
2078 | 2154 | ||
2079 | /// <summary> | 2155 | /// <summary> |
@@ -2165,6 +2241,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2165 | /// </summary> | 2241 | /// </summary> |
2166 | public void DeleteAllSceneObjects() | 2242 | public void DeleteAllSceneObjects() |
2167 | { | 2243 | { |
2244 | DeleteAllSceneObjects(false); | ||
2245 | } | ||
2246 | |||
2247 | /// <summary> | ||
2248 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2249 | /// </summary> | ||
2250 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2251 | { | ||
2252 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2168 | lock (Entities) | 2253 | lock (Entities) |
2169 | { | 2254 | { |
2170 | EntityBase[] entities = Entities.GetEntities(); | 2255 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2173,11 +2258,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2173 | if (e is SceneObjectGroup) | 2258 | if (e is SceneObjectGroup) |
2174 | { | 2259 | { |
2175 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2260 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2176 | if (!sog.IsAttachment) | 2261 | if (sog != null && !sog.IsAttachment) |
2177 | DeleteSceneObject((SceneObjectGroup)e, false); | 2262 | { |
2263 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2264 | { | ||
2265 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2266 | } | ||
2267 | else | ||
2268 | { | ||
2269 | toReturn.Add((SceneObjectGroup)e); | ||
2270 | } | ||
2271 | } | ||
2178 | } | 2272 | } |
2179 | } | 2273 | } |
2180 | } | 2274 | } |
2275 | if (toReturn.Count > 0) | ||
2276 | { | ||
2277 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2278 | } | ||
2181 | } | 2279 | } |
2182 | 2280 | ||
2183 | /// <summary> | 2281 | /// <summary> |
@@ -2229,6 +2327,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2229 | } | 2327 | } |
2230 | 2328 | ||
2231 | group.DeleteGroupFromScene(silent); | 2329 | group.DeleteGroupFromScene(silent); |
2330 | if (!silent) | ||
2331 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2232 | 2332 | ||
2233 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2333 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2234 | } | 2334 | } |
@@ -2519,7 +2619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2519 | // If the user is banned, we won't let any of their objects | 2619 | // If the user is banned, we won't let any of their objects |
2520 | // enter. Period. | 2620 | // enter. Period. |
2521 | // | 2621 | // |
2522 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2622 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2523 | { | 2623 | { |
2524 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2624 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2525 | return false; | 2625 | return false; |
@@ -2527,6 +2627,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2527 | 2627 | ||
2528 | if (newPosition != Vector3.Zero) | 2628 | if (newPosition != Vector3.Zero) |
2529 | newObject.RootPart.GroupPosition = newPosition; | 2629 | newObject.RootPart.GroupPosition = newPosition; |
2630 | if (newObject.RootPart.KeyframeMotion != null) | ||
2631 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2530 | 2632 | ||
2531 | if (!AddSceneObject(newObject)) | 2633 | if (!AddSceneObject(newObject)) |
2532 | { | 2634 | { |
@@ -2571,6 +2673,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2571 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2673 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2572 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2674 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2573 | { | 2675 | { |
2676 | if (sceneObject.OwnerID == UUID.Zero) | ||
2677 | { | ||
2678 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2679 | return false; | ||
2680 | } | ||
2681 | |||
2682 | // If the user is banned, we won't let any of their objects | ||
2683 | // enter. Period. | ||
2684 | // | ||
2685 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2686 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2687 | { | ||
2688 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2689 | |||
2690 | return false; | ||
2691 | } | ||
2692 | |||
2574 | // Force allocation of new LocalId | 2693 | // Force allocation of new LocalId |
2575 | // | 2694 | // |
2576 | SceneObjectPart[] parts = sceneObject.Parts; | 2695 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2604,16 +2723,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2604 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2723 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2605 | 2724 | ||
2606 | if (AttachmentsModule != null) | 2725 | if (AttachmentsModule != null) |
2607 | AttachmentsModule.AttachObject(sp, grp, 0, false); | 2726 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); |
2608 | } | 2727 | } |
2609 | else | 2728 | else |
2610 | { | 2729 | { |
2730 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2611 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2731 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2612 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2732 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2613 | } | 2733 | } |
2734 | if (sceneObject.OwnerID == UUID.Zero) | ||
2735 | { | ||
2736 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2737 | return false; | ||
2738 | } | ||
2614 | } | 2739 | } |
2615 | else | 2740 | else |
2616 | { | 2741 | { |
2742 | if (sceneObject.OwnerID == UUID.Zero) | ||
2743 | { | ||
2744 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2745 | return false; | ||
2746 | } | ||
2617 | AddRestoredSceneObject(sceneObject, true, false); | 2747 | AddRestoredSceneObject(sceneObject, true, false); |
2618 | } | 2748 | } |
2619 | 2749 | ||
@@ -2630,6 +2760,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2630 | return 2; // StateSource.PrimCrossing | 2760 | return 2; // StateSource.PrimCrossing |
2631 | } | 2761 | } |
2632 | 2762 | ||
2763 | public int GetUserFlags(UUID user) | ||
2764 | { | ||
2765 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2766 | /* | ||
2767 | ScenePresence sp; | ||
2768 | if (TryGetScenePresence(user, out sp)) | ||
2769 | { | ||
2770 | return sp.UserFlags; | ||
2771 | } | ||
2772 | else | ||
2773 | { | ||
2774 | */ | ||
2775 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2776 | if (uac == null) | ||
2777 | return 0; | ||
2778 | return uac.UserFlags; | ||
2779 | //} | ||
2780 | } | ||
2633 | #endregion | 2781 | #endregion |
2634 | 2782 | ||
2635 | #region Add/Remove Avatar Methods | 2783 | #region Add/Remove Avatar Methods |
@@ -2643,7 +2791,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2643 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2791 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2644 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2792 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2645 | 2793 | ||
2646 | // CheckHeartbeat(); | 2794 | CheckHeartbeat(); |
2647 | 2795 | ||
2648 | ScenePresence sp = GetScenePresence(client.AgentId); | 2796 | ScenePresence sp = GetScenePresence(client.AgentId); |
2649 | 2797 | ||
@@ -2697,7 +2845,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2697 | 2845 | ||
2698 | EventManager.TriggerOnNewClient(client); | 2846 | EventManager.TriggerOnNewClient(client); |
2699 | if (vialogin) | 2847 | if (vialogin) |
2848 | { | ||
2700 | EventManager.TriggerOnClientLogin(client); | 2849 | EventManager.TriggerOnClientLogin(client); |
2850 | // Send initial parcel data | ||
2851 | Vector3 pos = sp.AbsolutePosition; | ||
2852 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2853 | land.SendLandUpdateToClient(client); | ||
2854 | } | ||
2701 | 2855 | ||
2702 | return sp; | 2856 | return sp; |
2703 | } | 2857 | } |
@@ -2786,19 +2940,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2786 | // and the scene presence and the client, if they exist | 2940 | // and the scene presence and the client, if they exist |
2787 | try | 2941 | try |
2788 | { | 2942 | { |
2789 | // We need to wait for the client to make UDP contact first. | 2943 | ScenePresence sp = GetScenePresence(agentID); |
2790 | // It's the UDP contact that creates the scene presence | 2944 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2791 | ScenePresence sp = WaitGetScenePresence(agentID); | 2945 | |
2792 | if (sp != null) | 2946 | if (sp != null) |
2793 | { | ||
2794 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2795 | |||
2796 | sp.ControllingClient.Close(); | 2947 | sp.ControllingClient.Close(); |
2797 | } | 2948 | |
2798 | else | ||
2799 | { | ||
2800 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2801 | } | ||
2802 | // BANG! SLASH! | 2949 | // BANG! SLASH! |
2803 | m_authenticateHandler.RemoveCircuit(agentID); | 2950 | m_authenticateHandler.RemoveCircuit(agentID); |
2804 | 2951 | ||
@@ -2843,6 +2990,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2843 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2990 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2844 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2991 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2845 | 2992 | ||
2993 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2994 | |||
2846 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2995 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2847 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2996 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2848 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2997 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2899,6 +3048,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2899 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3048 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2900 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3049 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2901 | client.OnCopyInventoryItem += CopyInventoryItem; | 3050 | client.OnCopyInventoryItem += CopyInventoryItem; |
3051 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2902 | client.OnMoveInventoryItem += MoveInventoryItem; | 3052 | client.OnMoveInventoryItem += MoveInventoryItem; |
2903 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3053 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2904 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3054 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2970,6 +3120,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2970 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3120 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2971 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3121 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2972 | 3122 | ||
3123 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3124 | |||
2973 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3125 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2974 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3126 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2975 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3127 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3072,7 +3224,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3072 | /// </summary> | 3224 | /// </summary> |
3073 | /// <param name="agentId">The avatar's Unique ID</param> | 3225 | /// <param name="agentId">The avatar's Unique ID</param> |
3074 | /// <param name="client">The IClientAPI for the client</param> | 3226 | /// <param name="client">The IClientAPI for the client</param> |
3075 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3227 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3076 | { | 3228 | { |
3077 | if (EntityTransferModule != null) | 3229 | if (EntityTransferModule != null) |
3078 | { | 3230 | { |
@@ -3083,6 +3235,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3083 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3235 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3084 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3236 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3085 | } | 3237 | } |
3238 | return false; | ||
3086 | } | 3239 | } |
3087 | 3240 | ||
3088 | /// <summary> | 3241 | /// <summary> |
@@ -3192,6 +3345,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3192 | /// <param name="flags"></param> | 3345 | /// <param name="flags"></param> |
3193 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3346 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3194 | { | 3347 | { |
3348 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3349 | ScenePresence presence; | ||
3350 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3351 | { | ||
3352 | if (presence.Appearance != null) | ||
3353 | { | ||
3354 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3355 | } | ||
3356 | } | ||
3357 | |||
3195 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3358 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3196 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3359 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3197 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3360 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3320,6 +3483,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3320 | avatar.Close(); | 3483 | avatar.Close(); |
3321 | 3484 | ||
3322 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3485 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3486 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3323 | } | 3487 | } |
3324 | catch (Exception e) | 3488 | catch (Exception e) |
3325 | { | 3489 | { |
@@ -3513,13 +3677,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3513 | sp = null; | 3677 | sp = null; |
3514 | } | 3678 | } |
3515 | 3679 | ||
3516 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3517 | 3680 | ||
3518 | //On login test land permisions | 3681 | //On login test land permisions |
3519 | if (vialogin) | 3682 | if (vialogin) |
3520 | { | 3683 | { |
3521 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3684 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3685 | if (cache != null) | ||
3686 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3687 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3522 | { | 3688 | { |
3689 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3523 | return false; | 3690 | return false; |
3524 | } | 3691 | } |
3525 | } | 3692 | } |
@@ -3542,9 +3709,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3542 | 3709 | ||
3543 | try | 3710 | try |
3544 | { | 3711 | { |
3545 | if (!AuthorizeUser(agent, out reason)) | 3712 | // Always check estate if this is a login. Always |
3546 | return false; | 3713 | // check if banned regions are to be blacked out. |
3547 | } catch (Exception e) | 3714 | if (vialogin || (!m_seeIntoBannedRegion)) |
3715 | { | ||
3716 | if (!AuthorizeUser(agent, out reason)) | ||
3717 | return false; | ||
3718 | } | ||
3719 | } | ||
3720 | catch (Exception e) | ||
3548 | { | 3721 | { |
3549 | m_log.ErrorFormat( | 3722 | m_log.ErrorFormat( |
3550 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3723 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3675,6 +3848,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3675 | } | 3848 | } |
3676 | 3849 | ||
3677 | // Honor parcel landing type and position. | 3850 | // Honor parcel landing type and position. |
3851 | /* | ||
3852 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3678 | if (land != null) | 3853 | if (land != null) |
3679 | { | 3854 | { |
3680 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3855 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3682,25 +3857,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3682 | agent.startpos = land.LandData.UserLocation; | 3857 | agent.startpos = land.LandData.UserLocation; |
3683 | } | 3858 | } |
3684 | } | 3859 | } |
3860 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3685 | } | 3861 | } |
3686 | 3862 | ||
3687 | return true; | 3863 | return true; |
3688 | } | 3864 | } |
3689 | 3865 | ||
3690 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3866 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3691 | { | 3867 | { |
3692 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3868 | reason = String.Empty; |
3693 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3869 | if (Permissions.IsGod(agentID)) |
3870 | return true; | ||
3871 | |||
3872 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3873 | if (land == null) | ||
3874 | return false; | ||
3875 | |||
3876 | bool banned = land.IsBannedFromLand(agentID); | ||
3877 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3694 | 3878 | ||
3695 | if (banned || restricted) | 3879 | if (banned || restricted) |
3696 | { | 3880 | { |
3697 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3881 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3698 | if (nearestParcel != null) | 3882 | if (nearestParcel != null) |
3699 | { | 3883 | { |
3700 | //Move agent to nearest allowed | 3884 | //Move agent to nearest allowed |
3701 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3885 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3702 | agent.startpos.X = newPosition.X; | 3886 | posX = newPosition.X; |
3703 | agent.startpos.Y = newPosition.Y; | 3887 | posY = newPosition.Y; |
3704 | } | 3888 | } |
3705 | else | 3889 | else |
3706 | { | 3890 | { |
@@ -3762,7 +3946,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3762 | 3946 | ||
3763 | if (!m_strictAccessControl) return true; | 3947 | if (!m_strictAccessControl) return true; |
3764 | if (Permissions.IsGod(agent.AgentID)) return true; | 3948 | if (Permissions.IsGod(agent.AgentID)) return true; |
3765 | 3949 | ||
3766 | if (AuthorizationService != null) | 3950 | if (AuthorizationService != null) |
3767 | { | 3951 | { |
3768 | if (!AuthorizationService.IsAuthorizedForRegion( | 3952 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3777,7 +3961,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3777 | 3961 | ||
3778 | if (RegionInfo.EstateSettings != null) | 3962 | if (RegionInfo.EstateSettings != null) |
3779 | { | 3963 | { |
3780 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 3964 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3781 | { | 3965 | { |
3782 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3966 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3783 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3967 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3967,6 +4151,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3967 | 4151 | ||
3968 | // XPTO: if this agent is not allowed here as root, always return false | 4152 | // XPTO: if this agent is not allowed here as root, always return false |
3969 | 4153 | ||
4154 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4155 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4156 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4157 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4158 | { | ||
4159 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4160 | return false; | ||
4161 | } | ||
4162 | |||
3970 | // TODO: This check should probably be in QueryAccess(). | 4163 | // TODO: This check should probably be in QueryAccess(). |
3971 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4164 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3972 | if (nearestParcel == null) | 4165 | if (nearestParcel == null) |
@@ -4060,12 +4253,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4060 | return false; | 4253 | return false; |
4061 | } | 4254 | } |
4062 | 4255 | ||
4256 | public bool IncomingCloseAgent(UUID agentID) | ||
4257 | { | ||
4258 | return IncomingCloseAgent(agentID, false); | ||
4259 | } | ||
4260 | |||
4261 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4262 | { | ||
4263 | return IncomingCloseAgent(agentID, true); | ||
4264 | } | ||
4265 | |||
4063 | /// <summary> | 4266 | /// <summary> |
4064 | /// Tell a single agent to disconnect from the region. | 4267 | /// Tell a single agent to disconnect from the region. |
4065 | /// </summary> | 4268 | /// </summary> |
4066 | /// <param name="regionHandle"></param> | ||
4067 | /// <param name="agentID"></param> | 4269 | /// <param name="agentID"></param> |
4068 | public bool IncomingCloseAgent(UUID agentID) | 4270 | /// <param name="childOnly"></param> |
4271 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
4069 | { | 4272 | { |
4070 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4273 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
4071 | 4274 | ||
@@ -4669,35 +4872,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4669 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 4872 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4670 | } | 4873 | } |
4671 | 4874 | ||
4672 | public int GetHealth() | 4875 | public int GetHealth(out int flags, out string message) |
4673 | { | 4876 | { |
4674 | // Returns: | 4877 | // Returns: |
4675 | // 1 = sim is up and accepting http requests. The heartbeat has | 4878 | // 1 = sim is up and accepting http requests. The heartbeat has |
4676 | // stopped and the sim is probably locked up, but a remote | 4879 | // stopped and the sim is probably locked up, but a remote |
4677 | // admin restart may succeed | 4880 | // admin restart may succeed |
4678 | // | 4881 | // |
4679 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4882 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4680 | // usable for people within and logins _may_ work | 4883 | // usable for people within |
4884 | // | ||
4885 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4886 | // unstable and will not accept new logins | ||
4681 | // | 4887 | // |
4682 | // 3 = We have seen a new user enter within the past 4 minutes | 4888 | // 4 = Sim is up and both packet threads are running. Sim is |
4889 | // likely usable | ||
4890 | // | ||
4891 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4683 | // which can be seen as positive confirmation of sim health | 4892 | // which can be seen as positive confirmation of sim health |
4684 | // | 4893 | // |
4894 | |||
4895 | flags = 0; | ||
4896 | message = String.Empty; | ||
4897 | |||
4898 | CheckHeartbeat(); | ||
4899 | |||
4900 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4901 | { | ||
4902 | // We're still starting | ||
4903 | // 0 means "in startup", it can't happen another way, since | ||
4904 | // to get here, we must be able to accept http connections | ||
4905 | return 0; | ||
4906 | } | ||
4907 | |||
4685 | int health=1; // Start at 1, means we're up | 4908 | int health=1; // Start at 1, means we're up |
4686 | 4909 | ||
4687 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4910 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4688 | health += 1; | 4911 | { |
4912 | health+=1; | ||
4913 | flags |= 1; | ||
4914 | } | ||
4915 | |||
4916 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4917 | { | ||
4918 | health+=1; | ||
4919 | flags |= 2; | ||
4920 | } | ||
4921 | |||
4922 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4923 | { | ||
4924 | health+=1; | ||
4925 | flags |= 4; | ||
4926 | } | ||
4689 | else | 4927 | else |
4928 | { | ||
4929 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4930 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4931 | proc.EnableRaisingEvents=false; | ||
4932 | proc.StartInfo.FileName = "/bin/kill"; | ||
4933 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4934 | proc.Start(); | ||
4935 | proc.WaitForExit(); | ||
4936 | Thread.Sleep(1000); | ||
4937 | Environment.Exit(1); | ||
4938 | } | ||
4939 | |||
4940 | if (flags != 7) | ||
4690 | return health; | 4941 | return health; |
4691 | 4942 | ||
4692 | // A login in the last 4 mins? We can't be doing too badly | 4943 | // A login in the last 4 mins? We can't be doing too badly |
4693 | // | 4944 | // |
4694 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4945 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4695 | health++; | 4946 | health++; |
4696 | else | 4947 | else |
4697 | return health; | 4948 | return health; |
4698 | 4949 | ||
4699 | // CheckHeartbeat(); | ||
4700 | |||
4701 | return health; | 4950 | return health; |
4702 | } | 4951 | } |
4703 | 4952 | ||
@@ -4785,7 +5034,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4785 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5034 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4786 | if (wasUsingPhysics) | 5035 | if (wasUsingPhysics) |
4787 | { | 5036 | { |
4788 | 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 | 5037 | 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 |
4789 | } | 5038 | } |
4790 | } | 5039 | } |
4791 | 5040 | ||
@@ -4884,14 +5133,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4884 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5133 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4885 | } | 5134 | } |
4886 | 5135 | ||
4887 | // private void CheckHeartbeat() | 5136 | private void CheckHeartbeat() |
4888 | // { | 5137 | { |
4889 | // if (m_firstHeartbeat) | 5138 | if (m_firstHeartbeat) |
4890 | // return; | 5139 | return; |
4891 | // | 5140 | |
4892 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5141 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4893 | // StartTimer(); | 5142 | Start(); |
4894 | // } | 5143 | } |
4895 | 5144 | ||
4896 | public override ISceneObject DeserializeObject(string representation) | 5145 | public override ISceneObject DeserializeObject(string representation) |
4897 | { | 5146 | { |
@@ -4903,9 +5152,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4903 | get { return m_allowScriptCrossings; } | 5152 | get { return m_allowScriptCrossings; } |
4904 | } | 5153 | } |
4905 | 5154 | ||
4906 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5155 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4907 | { | 5156 | { |
4908 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5157 | return GetNearestAllowedPosition(avatar, null); |
5158 | } | ||
5159 | |||
5160 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
5161 | { | ||
5162 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
4909 | 5163 | ||
4910 | if (nearestParcel != null) | 5164 | if (nearestParcel != null) |
4911 | { | 5165 | { |
@@ -4914,10 +5168,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4914 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5168 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4915 | if (nearestPoint != null) | 5169 | if (nearestPoint != null) |
4916 | { | 5170 | { |
4917 | // m_log.DebugFormat( | 5171 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4918 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4919 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4920 | |||
4921 | return nearestPoint.Value; | 5172 | return nearestPoint.Value; |
4922 | } | 5173 | } |
4923 | 5174 | ||
@@ -4927,17 +5178,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4927 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5178 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4928 | if (nearestPoint != null) | 5179 | if (nearestPoint != null) |
4929 | { | 5180 | { |
4930 | // m_log.DebugFormat( | 5181 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4931 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4932 | |||
4933 | return nearestPoint.Value; | 5182 | return nearestPoint.Value; |
4934 | } | 5183 | } |
4935 | 5184 | ||
4936 | //Ultimate backup if we have no idea where they are | 5185 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4937 | // m_log.DebugFormat( | 5186 | if (dest != excludeParcel) |
4938 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5187 | { |
5188 | // Ultimate backup if we have no idea where they are and | ||
5189 | // the last allowed position was in another parcel | ||
5190 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5191 | return avatar.lastKnownAllowedPosition; | ||
5192 | } | ||
4939 | 5193 | ||
4940 | return avatar.lastKnownAllowedPosition; | 5194 | // else fall through to region edge |
4941 | } | 5195 | } |
4942 | 5196 | ||
4943 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5197 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4971,13 +5225,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4971 | 5225 | ||
4972 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5226 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4973 | { | 5227 | { |
5228 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5229 | } | ||
5230 | |||
5231 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5232 | { | ||
4974 | List<ILandObject> all = AllParcels(); | 5233 | List<ILandObject> all = AllParcels(); |
4975 | float minParcelDistance = float.MaxValue; | 5234 | float minParcelDistance = float.MaxValue; |
4976 | ILandObject nearestParcel = null; | 5235 | ILandObject nearestParcel = null; |
4977 | 5236 | ||
4978 | foreach (var parcel in all) | 5237 | foreach (var parcel in all) |
4979 | { | 5238 | { |
4980 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5239 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4981 | { | 5240 | { |
4982 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5241 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4983 | if (parcelDistance < minParcelDistance) | 5242 | if (parcelDistance < minParcelDistance) |
@@ -5219,7 +5478,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5219 | mapModule.GenerateMaptile(); | 5478 | mapModule.GenerateMaptile(); |
5220 | } | 5479 | } |
5221 | 5480 | ||
5222 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5481 | // public void CleanDroppedAttachments() |
5482 | // { | ||
5483 | // List<SceneObjectGroup> objectsToDelete = | ||
5484 | // new List<SceneObjectGroup>(); | ||
5485 | // | ||
5486 | // lock (m_cleaningAttachments) | ||
5487 | // { | ||
5488 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5489 | // { | ||
5490 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5491 | // { | ||
5492 | // UUID agentID = grp.OwnerID; | ||
5493 | // if (agentID == UUID.Zero) | ||
5494 | // { | ||
5495 | // objectsToDelete.Add(grp); | ||
5496 | // return; | ||
5497 | // } | ||
5498 | // | ||
5499 | // ScenePresence sp = GetScenePresence(agentID); | ||
5500 | // if (sp == null) | ||
5501 | // { | ||
5502 | // objectsToDelete.Add(grp); | ||
5503 | // return; | ||
5504 | // } | ||
5505 | // } | ||
5506 | // }); | ||
5507 | // } | ||
5508 | // | ||
5509 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5510 | // { | ||
5511 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5512 | // DeleteSceneObject(grp, true); | ||
5513 | // } | ||
5514 | // } | ||
5515 | |||
5516 | public void ThreadAlive(int threadCode) | ||
5517 | { | ||
5518 | switch(threadCode) | ||
5519 | { | ||
5520 | case 1: // Incoming | ||
5521 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5522 | break; | ||
5523 | case 2: // Incoming | ||
5524 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5525 | break; | ||
5526 | } | ||
5527 | } | ||
5528 | |||
5529 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5223 | { | 5530 | { |
5224 | RegenerateMaptile(); | 5531 | RegenerateMaptile(); |
5225 | 5532 | ||
@@ -5247,6 +5554,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5247 | /// <returns></returns> | 5554 | /// <returns></returns> |
5248 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5555 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5249 | { | 5556 | { |
5557 | reason = "You are banned from the region"; | ||
5558 | |||
5250 | if (EntityTransferModule.IsInTransit(agentID)) | 5559 | if (EntityTransferModule.IsInTransit(agentID)) |
5251 | { | 5560 | { |
5252 | reason = "Agent is still in transit from this region"; | 5561 | reason = "Agent is still in transit from this region"; |
@@ -5258,6 +5567,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5258 | return false; | 5567 | return false; |
5259 | } | 5568 | } |
5260 | 5569 | ||
5570 | if (Permissions.IsGod(agentID)) | ||
5571 | { | ||
5572 | reason = String.Empty; | ||
5573 | return true; | ||
5574 | } | ||
5575 | |||
5261 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5576 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5262 | // However, the long term fix is to make sure root agent count is always accurate. | 5577 | // However, the long term fix is to make sure root agent count is always accurate. |
5263 | m_sceneGraph.RecalculateStats(); | 5578 | m_sceneGraph.RecalculateStats(); |
@@ -5278,6 +5593,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5278 | } | 5593 | } |
5279 | } | 5594 | } |
5280 | 5595 | ||
5596 | ScenePresence presence = GetScenePresence(agentID); | ||
5597 | IClientAPI client = null; | ||
5598 | AgentCircuitData aCircuit = null; | ||
5599 | |||
5600 | if (presence != null) | ||
5601 | { | ||
5602 | client = presence.ControllingClient; | ||
5603 | if (client != null) | ||
5604 | aCircuit = client.RequestClientInfo(); | ||
5605 | } | ||
5606 | |||
5607 | // We may be called before there is a presence or a client. | ||
5608 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5609 | if (client == null) | ||
5610 | { | ||
5611 | aCircuit = new AgentCircuitData(); | ||
5612 | aCircuit.AgentID = agentID; | ||
5613 | aCircuit.firstname = String.Empty; | ||
5614 | aCircuit.lastname = String.Empty; | ||
5615 | } | ||
5616 | |||
5617 | try | ||
5618 | { | ||
5619 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5620 | { | ||
5621 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5622 | return false; | ||
5623 | } | ||
5624 | } | ||
5625 | catch (Exception e) | ||
5626 | { | ||
5627 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5628 | return false; | ||
5629 | } | ||
5630 | |||
5281 | if (position == Vector3.Zero) // Teleport | 5631 | if (position == Vector3.Zero) // Teleport |
5282 | { | 5632 | { |
5283 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5633 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5306,13 +5656,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5306 | } | 5656 | } |
5307 | } | 5657 | } |
5308 | } | 5658 | } |
5659 | |||
5660 | float posX = 128.0f; | ||
5661 | float posY = 128.0f; | ||
5662 | |||
5663 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5664 | { | ||
5665 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5666 | return false; | ||
5667 | } | ||
5668 | } | ||
5669 | else // Walking | ||
5670 | { | ||
5671 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5672 | if (land == null) | ||
5673 | return false; | ||
5674 | |||
5675 | bool banned = land.IsBannedFromLand(agentID); | ||
5676 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5677 | |||
5678 | if (banned || restricted) | ||
5679 | return false; | ||
5309 | } | 5680 | } |
5310 | 5681 | ||
5311 | reason = String.Empty; | 5682 | reason = String.Empty; |
5312 | return true; | 5683 | return true; |
5313 | } | 5684 | } |
5314 | 5685 | ||
5315 | /// <summary> | 5686 | public void StartTimerWatchdog() |
5687 | { | ||
5688 | m_timerWatchdog.Interval = 1000; | ||
5689 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5690 | m_timerWatchdog.AutoReset = true; | ||
5691 | m_timerWatchdog.Start(); | ||
5692 | } | ||
5693 | |||
5694 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5695 | { | ||
5696 | CheckHeartbeat(); | ||
5697 | } | ||
5698 | |||
5316 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5699 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5317 | /// autopilot that moves an avatar to a sit target!. | 5700 | /// autopilot that moves an avatar to a sit target!. |
5318 | /// </summary> | 5701 | /// </summary> |