diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 684 |
1 files changed, 522 insertions, 162 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 44cd30a..cf3270d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -118,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | // TODO: need to figure out how allow client agents but deny | 118 | // TODO: need to figure out how allow client agents but deny |
119 | // root agents when ACL denies access to root agent | 119 | // root agents when ACL denies access to root agent |
120 | public bool m_strictAccessControl = true; | 120 | public bool m_strictAccessControl = true; |
121 | public bool m_seeIntoBannedRegion = false; | ||
121 | public int MaxUndoCount = 5; | 122 | public int MaxUndoCount = 5; |
122 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 123 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
123 | public bool LoginLock = false; | 124 | public bool LoginLock = false; |
@@ -133,12 +134,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | 134 | ||
134 | protected int m_splitRegionID; | 135 | protected int m_splitRegionID; |
135 | protected Timer m_restartWaitTimer = new Timer(); | 136 | protected Timer m_restartWaitTimer = new Timer(); |
137 | protected Timer m_timerWatchdog = new Timer(); | ||
136 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 138 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
137 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 139 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
138 | protected string m_simulatorVersion = "OpenSimulator Server"; | 140 | protected string m_simulatorVersion = "OpenSimulator Server"; |
139 | protected ModuleLoader m_moduleLoader; | 141 | protected ModuleLoader m_moduleLoader; |
140 | protected AgentCircuitManager m_authenticateHandler; | 142 | protected AgentCircuitManager m_authenticateHandler; |
141 | protected SceneCommunicationService m_sceneGridService; | 143 | protected SceneCommunicationService m_sceneGridService; |
144 | protected ISnmpModule m_snmpService = null; | ||
142 | 145 | ||
143 | protected ISimulationDataService m_SimulationDataService; | 146 | protected ISimulationDataService m_SimulationDataService; |
144 | protected IEstateDataService m_EstateDataService; | 147 | protected IEstateDataService m_EstateDataService; |
@@ -201,7 +204,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
201 | private int m_update_events = 1; | 204 | private int m_update_events = 1; |
202 | private int m_update_backup = 200; | 205 | private int m_update_backup = 200; |
203 | private int m_update_terrain = 50; | 206 | private int m_update_terrain = 50; |
204 | // private int m_update_land = 1; | 207 | private int m_update_land = 10; |
205 | private int m_update_coarse_locations = 50; | 208 | private int m_update_coarse_locations = 50; |
206 | 209 | ||
207 | private int agentMS; | 210 | private int agentMS; |
@@ -220,6 +223,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
220 | /// </summary> | 223 | /// </summary> |
221 | private int m_lastFrameTick; | 224 | private int m_lastFrameTick; |
222 | 225 | ||
226 | public bool CombineRegions = false; | ||
223 | /// <summary> | 227 | /// <summary> |
224 | /// Tick at which the last maintenance run occurred. | 228 | /// Tick at which the last maintenance run occurred. |
225 | /// </summary> | 229 | /// </summary> |
@@ -250,6 +254,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
250 | /// </summary> | 254 | /// </summary> |
251 | private int m_LastLogin; | 255 | private int m_LastLogin; |
252 | 256 | ||
257 | private int m_lastIncoming; | ||
258 | private int m_lastOutgoing; | ||
259 | private int m_hbRestarts = 0; | ||
260 | |||
261 | |||
253 | /// <summary> | 262 | /// <summary> |
254 | /// Thread that runs the scene loop. | 263 | /// Thread that runs the scene loop. |
255 | /// </summary> | 264 | /// </summary> |
@@ -265,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | private volatile bool m_shuttingDown; | 274 | private volatile bool m_shuttingDown; |
266 | 275 | ||
267 | // private int m_lastUpdate; | 276 | // private int m_lastUpdate; |
268 | // private bool m_firstHeartbeat = true; | 277 | private bool m_firstHeartbeat = true; |
269 | 278 | ||
270 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 279 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
271 | private bool m_reprioritizationEnabled = true; | 280 | private bool m_reprioritizationEnabled = true; |
@@ -310,6 +319,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
310 | get { return m_sceneGridService; } | 319 | get { return m_sceneGridService; } |
311 | } | 320 | } |
312 | 321 | ||
322 | public ISnmpModule SnmpService | ||
323 | { | ||
324 | get | ||
325 | { | ||
326 | if (m_snmpService == null) | ||
327 | { | ||
328 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
329 | } | ||
330 | |||
331 | return m_snmpService; | ||
332 | } | ||
333 | } | ||
334 | |||
313 | public ISimulationDataService SimulationDataService | 335 | public ISimulationDataService SimulationDataService |
314 | { | 336 | { |
315 | get | 337 | get |
@@ -592,6 +614,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | m_EstateDataService = estateDataService; | 614 | m_EstateDataService = estateDataService; |
593 | m_regionHandle = m_regInfo.RegionHandle; | 615 | m_regionHandle = m_regInfo.RegionHandle; |
594 | m_regionName = m_regInfo.RegionName; | 616 | m_regionName = m_regInfo.RegionName; |
617 | m_lastIncoming = 0; | ||
618 | m_lastOutgoing = 0; | ||
595 | 619 | ||
596 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 620 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
597 | m_asyncSceneObjectDeleter.Enabled = true; | 621 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -676,98 +700,107 @@ namespace OpenSim.Region.Framework.Scenes | |||
676 | 700 | ||
677 | // Region config overrides global config | 701 | // Region config overrides global config |
678 | // | 702 | // |
679 | if (m_config.Configs["Startup"] != null) | 703 | try |
680 | { | 704 | { |
681 | IConfig startupConfig = m_config.Configs["Startup"]; | 705 | if (m_config.Configs["Startup"] != null) |
682 | |||
683 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | ||
684 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | ||
685 | if (!m_useBackup) | ||
686 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | ||
687 | |||
688 | //Animation states | ||
689 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
690 | |||
691 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); | ||
692 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | ||
693 | |||
694 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | ||
695 | if (RegionInfo.NonphysPrimMax > 0) | ||
696 | { | 706 | { |
697 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 707 | IConfig startupConfig = m_config.Configs["Startup"]; |
698 | } | ||
699 | 708 | ||
700 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 709 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
710 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | ||
711 | if (!m_useBackup) | ||
712 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | ||
713 | |||
714 | //Animation states | ||
715 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
701 | 716 | ||
702 | if (RegionInfo.PhysPrimMax > 0) | 717 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
703 | { | 718 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
704 | m_maxPhys = RegionInfo.PhysPrimMax; | ||
705 | } | ||
706 | 719 | ||
707 | // Here, if clamping is requested in either global or | 720 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
708 | // local config, it will be used | 721 | if (RegionInfo.NonphysPrimMax > 0) |
709 | // | 722 | { |
710 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | 723 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
711 | if (RegionInfo.ClampPrimSize) | 724 | } |
712 | { | ||
713 | m_clampPrimSize = true; | ||
714 | } | ||
715 | 725 | ||
716 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 726 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
717 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | ||
718 | m_dontPersistBefore = | ||
719 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | ||
720 | m_dontPersistBefore *= 10000000; | ||
721 | m_persistAfter = | ||
722 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
723 | m_persistAfter *= 10000000; | ||
724 | 727 | ||
725 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 728 | if (RegionInfo.PhysPrimMax > 0) |
729 | { | ||
730 | m_maxPhys = RegionInfo.PhysPrimMax; | ||
731 | } | ||
726 | 732 | ||
727 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 733 | // Here, if clamping is requested in either global or |
728 | if (packetConfig != null) | 734 | // local config, it will be used |
729 | { | 735 | // |
730 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | 736 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); |
731 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | 737 | if (RegionInfo.ClampPrimSize) |
732 | } | 738 | { |
739 | m_clampPrimSize = true; | ||
740 | } | ||
733 | 741 | ||
734 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 742 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
743 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | ||
744 | m_dontPersistBefore = | ||
745 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | ||
746 | m_dontPersistBefore *= 10000000; | ||
747 | m_persistAfter = | ||
748 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
749 | m_persistAfter *= 10000000; | ||
735 | 750 | ||
736 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 751 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
737 | if (m_generateMaptiles) | 752 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); |
738 | { | 753 | |
739 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | 754 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
740 | if (maptileRefresh != 0) | 755 | if (packetConfig != null) |
741 | { | 756 | { |
742 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 757 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
743 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | 758 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); |
744 | m_mapGenerationTimer.AutoReset = true; | ||
745 | m_mapGenerationTimer.Start(); | ||
746 | } | 759 | } |
747 | } | ||
748 | else | ||
749 | { | ||
750 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
751 | UUID tileID; | ||
752 | 760 | ||
753 | if (UUID.TryParse(tile, out tileID)) | 761 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
762 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
763 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
764 | |||
765 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | ||
766 | if (m_generateMaptiles) | ||
754 | { | 767 | { |
755 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 768 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
769 | if (maptileRefresh != 0) | ||
770 | { | ||
771 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | ||
772 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
773 | m_mapGenerationTimer.AutoReset = true; | ||
774 | m_mapGenerationTimer.Start(); | ||
775 | } | ||
756 | } | 776 | } |
757 | } | 777 | else |
778 | { | ||
779 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
780 | UUID tileID; | ||
758 | 781 | ||
759 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 782 | if (UUID.TryParse(tile, out tileID)) |
760 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 783 | { |
761 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 784 | RegionInfo.RegionSettings.TerrainImageID = tileID; |
762 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 785 | } |
763 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 786 | } |
764 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
765 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
766 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
767 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
768 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
769 | 787 | ||
770 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | 788 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
789 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | ||
790 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | ||
791 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | ||
792 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | ||
793 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
794 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
795 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
796 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
797 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
798 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | ||
799 | } | ||
800 | } | ||
801 | catch (Exception e) | ||
802 | { | ||
803 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
771 | } | 804 | } |
772 | 805 | ||
773 | #endregion Region Config | 806 | #endregion Region Config |
@@ -1198,7 +1231,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1198 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1231 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1199 | if (m_heartbeatThread != null) | 1232 | if (m_heartbeatThread != null) |
1200 | { | 1233 | { |
1234 | m_hbRestarts++; | ||
1235 | if(m_hbRestarts > 10) | ||
1236 | Environment.Exit(1); | ||
1237 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1238 | |||
1239 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1240 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1241 | //proc.EnableRaisingEvents=false; | ||
1242 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1243 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1244 | //proc.Start(); | ||
1245 | //proc.WaitForExit(); | ||
1246 | //Thread.Sleep(1000); | ||
1247 | //Environment.Exit(1); | ||
1201 | m_heartbeatThread.Abort(); | 1248 | m_heartbeatThread.Abort(); |
1249 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1202 | m_heartbeatThread = null; | 1250 | m_heartbeatThread = null; |
1203 | } | 1251 | } |
1204 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1252 | // m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1511,6 +1559,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1511 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1559 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); |
1512 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1560 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1513 | 1561 | ||
1562 | m_firstHeartbeat = false; | ||
1563 | |||
1514 | if (maintc > 0) | 1564 | if (maintc > 0) |
1515 | Thread.Sleep(maintc); | 1565 | Thread.Sleep(maintc); |
1516 | 1566 | ||
@@ -1540,9 +1590,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1540 | 1590 | ||
1541 | private void CheckAtTargets() | 1591 | private void CheckAtTargets() |
1542 | { | 1592 | { |
1543 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1593 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1544 | lock (m_groupsWithTargets) | 1594 | lock (m_groupsWithTargets) |
1545 | objs = m_groupsWithTargets.Values; | 1595 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1546 | 1596 | ||
1547 | foreach (SceneObjectGroup entry in objs) | 1597 | foreach (SceneObjectGroup entry in objs) |
1548 | entry.checkAtTargets(); | 1598 | entry.checkAtTargets(); |
@@ -1623,7 +1673,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1623 | msg.fromAgentName = "Server"; | 1673 | msg.fromAgentName = "Server"; |
1624 | msg.dialog = (byte)19; // Object msg | 1674 | msg.dialog = (byte)19; // Object msg |
1625 | msg.fromGroup = false; | 1675 | msg.fromGroup = false; |
1626 | msg.offline = (byte)0; | 1676 | msg.offline = (byte)1; |
1627 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1677 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1628 | msg.Position = Vector3.Zero; | 1678 | msg.Position = Vector3.Zero; |
1629 | msg.RegionID = RegionInfo.RegionID.Guid; | 1679 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1861,14 +1911,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1861 | /// <returns></returns> | 1911 | /// <returns></returns> |
1862 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1912 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1863 | { | 1913 | { |
1914 | |||
1915 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1916 | Vector3 wpos = Vector3.Zero; | ||
1917 | // Check for water surface intersection from above | ||
1918 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1919 | { | ||
1920 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1921 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1922 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1923 | wpos.Z = wheight; | ||
1924 | } | ||
1925 | |||
1864 | Vector3 pos = Vector3.Zero; | 1926 | Vector3 pos = Vector3.Zero; |
1865 | if (RayEndIsIntersection == (byte)1) | 1927 | if (RayEndIsIntersection == (byte)1) |
1866 | { | 1928 | { |
1867 | pos = RayEnd; | 1929 | pos = RayEnd; |
1868 | return pos; | ||
1869 | } | 1930 | } |
1870 | 1931 | else if (RayTargetID != UUID.Zero) | |
1871 | if (RayTargetID != UUID.Zero) | ||
1872 | { | 1932 | { |
1873 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1933 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1874 | 1934 | ||
@@ -1890,7 +1950,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1890 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1950 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1891 | 1951 | ||
1892 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1952 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1893 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1953 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1894 | float ScaleOffset = 0.5f; | 1954 | float ScaleOffset = 0.5f; |
1895 | 1955 | ||
1896 | // If we hit something | 1956 | // If we hit something |
@@ -1913,13 +1973,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1913 | //pos.Z -= 0.25F; | 1973 | //pos.Z -= 0.25F; |
1914 | 1974 | ||
1915 | } | 1975 | } |
1916 | |||
1917 | return pos; | ||
1918 | } | 1976 | } |
1919 | else | 1977 | else |
1920 | { | 1978 | { |
1921 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1979 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1922 | |||
1923 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1980 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1924 | 1981 | ||
1925 | // Un-comment the following line to print the raytrace results to the console. | 1982 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1928,13 +1985,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1928 | if (ei.HitTF) | 1985 | if (ei.HitTF) |
1929 | { | 1986 | { |
1930 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1987 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1931 | } else | 1988 | } |
1989 | else | ||
1932 | { | 1990 | { |
1933 | // fall back to our stupid functionality | 1991 | // fall back to our stupid functionality |
1934 | pos = RayEnd; | 1992 | pos = RayEnd; |
1935 | } | 1993 | } |
1936 | |||
1937 | return pos; | ||
1938 | } | 1994 | } |
1939 | } | 1995 | } |
1940 | else | 1996 | else |
@@ -1945,8 +2001,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1945 | //increase height so its above the ground. | 2001 | //increase height so its above the ground. |
1946 | //should be getting the normal of the ground at the rez point and using that? | 2002 | //should be getting the normal of the ground at the rez point and using that? |
1947 | pos.Z += scale.Z / 2f; | 2003 | pos.Z += scale.Z / 2f; |
1948 | return pos; | 2004 | // return pos; |
1949 | } | 2005 | } |
2006 | |||
2007 | // check against posible water intercept | ||
2008 | if (wpos.Z > pos.Z) pos = wpos; | ||
2009 | return pos; | ||
1950 | } | 2010 | } |
1951 | 2011 | ||
1952 | 2012 | ||
@@ -2030,7 +2090,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2030 | public bool AddRestoredSceneObject( | 2090 | public bool AddRestoredSceneObject( |
2031 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2091 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
2032 | { | 2092 | { |
2033 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2093 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2094 | if (result) | ||
2095 | sceneObject.IsDeleted = false; | ||
2096 | return result; | ||
2034 | } | 2097 | } |
2035 | 2098 | ||
2036 | /// <summary> | 2099 | /// <summary> |
@@ -2122,6 +2185,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2122 | /// </summary> | 2185 | /// </summary> |
2123 | public void DeleteAllSceneObjects() | 2186 | public void DeleteAllSceneObjects() |
2124 | { | 2187 | { |
2188 | DeleteAllSceneObjects(false); | ||
2189 | } | ||
2190 | |||
2191 | /// <summary> | ||
2192 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2193 | /// </summary> | ||
2194 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2195 | { | ||
2196 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2125 | lock (Entities) | 2197 | lock (Entities) |
2126 | { | 2198 | { |
2127 | EntityBase[] entities = Entities.GetEntities(); | 2199 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2130,11 +2202,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2130 | if (e is SceneObjectGroup) | 2202 | if (e is SceneObjectGroup) |
2131 | { | 2203 | { |
2132 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2204 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2133 | if (!sog.IsAttachment) | 2205 | if (sog != null && !sog.IsAttachment) |
2134 | DeleteSceneObject((SceneObjectGroup)e, false); | 2206 | { |
2207 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2208 | { | ||
2209 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2210 | } | ||
2211 | else | ||
2212 | { | ||
2213 | toReturn.Add((SceneObjectGroup)e); | ||
2214 | } | ||
2215 | } | ||
2135 | } | 2216 | } |
2136 | } | 2217 | } |
2137 | } | 2218 | } |
2219 | if (toReturn.Count > 0) | ||
2220 | { | ||
2221 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2222 | } | ||
2138 | } | 2223 | } |
2139 | 2224 | ||
2140 | /// <summary> | 2225 | /// <summary> |
@@ -2175,6 +2260,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2175 | } | 2260 | } |
2176 | 2261 | ||
2177 | group.DeleteGroupFromScene(silent); | 2262 | group.DeleteGroupFromScene(silent); |
2263 | if (!silent) | ||
2264 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2178 | 2265 | ||
2179 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2266 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2180 | } | 2267 | } |
@@ -2464,6 +2551,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2464 | 2551 | ||
2465 | if (newPosition != Vector3.Zero) | 2552 | if (newPosition != Vector3.Zero) |
2466 | newObject.RootPart.GroupPosition = newPosition; | 2553 | newObject.RootPart.GroupPosition = newPosition; |
2554 | if (newObject.RootPart.KeyframeMotion != null) | ||
2555 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2467 | 2556 | ||
2468 | if (!AddSceneObject(newObject)) | 2557 | if (!AddSceneObject(newObject)) |
2469 | { | 2558 | { |
@@ -2532,10 +2621,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2532 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2621 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2533 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2622 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2534 | { | 2623 | { |
2624 | if (sceneObject.OwnerID == UUID.Zero) | ||
2625 | { | ||
2626 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2627 | return false; | ||
2628 | } | ||
2629 | |||
2535 | // If the user is banned, we won't let any of their objects | 2630 | // If the user is banned, we won't let any of their objects |
2536 | // enter. Period. | 2631 | // enter. Period. |
2537 | // | 2632 | // |
2538 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2633 | int flags = GetUserFlags(sceneObject.OwnerID); |
2634 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2539 | { | 2635 | { |
2540 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2636 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2541 | 2637 | ||
@@ -2581,12 +2677,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2581 | } | 2677 | } |
2582 | else | 2678 | else |
2583 | { | 2679 | { |
2680 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2584 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2681 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2585 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2682 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2586 | } | 2683 | } |
2684 | if (sceneObject.OwnerID == UUID.Zero) | ||
2685 | { | ||
2686 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2687 | return false; | ||
2688 | } | ||
2587 | } | 2689 | } |
2588 | else | 2690 | else |
2589 | { | 2691 | { |
2692 | if (sceneObject.OwnerID == UUID.Zero) | ||
2693 | { | ||
2694 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2695 | return false; | ||
2696 | } | ||
2590 | AddRestoredSceneObject(sceneObject, true, false); | 2697 | AddRestoredSceneObject(sceneObject, true, false); |
2591 | 2698 | ||
2592 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2699 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2615,6 +2722,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2615 | return 2; // StateSource.PrimCrossing | 2722 | return 2; // StateSource.PrimCrossing |
2616 | } | 2723 | } |
2617 | 2724 | ||
2725 | public int GetUserFlags(UUID user) | ||
2726 | { | ||
2727 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2728 | /* | ||
2729 | ScenePresence sp; | ||
2730 | if (TryGetScenePresence(user, out sp)) | ||
2731 | { | ||
2732 | return sp.UserFlags; | ||
2733 | } | ||
2734 | else | ||
2735 | { | ||
2736 | */ | ||
2737 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2738 | if (uac == null) | ||
2739 | return 0; | ||
2740 | return uac.UserFlags; | ||
2741 | //} | ||
2742 | } | ||
2618 | #endregion | 2743 | #endregion |
2619 | 2744 | ||
2620 | #region Add/Remove Avatar Methods | 2745 | #region Add/Remove Avatar Methods |
@@ -2628,7 +2753,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2628 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2753 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2629 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2754 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2630 | 2755 | ||
2631 | // CheckHeartbeat(); | 2756 | CheckHeartbeat(); |
2632 | 2757 | ||
2633 | ScenePresence sp = GetScenePresence(client.AgentId); | 2758 | ScenePresence sp = GetScenePresence(client.AgentId); |
2634 | 2759 | ||
@@ -2681,7 +2806,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2681 | 2806 | ||
2682 | EventManager.TriggerOnNewClient(client); | 2807 | EventManager.TriggerOnNewClient(client); |
2683 | if (vialogin) | 2808 | if (vialogin) |
2809 | { | ||
2684 | EventManager.TriggerOnClientLogin(client); | 2810 | EventManager.TriggerOnClientLogin(client); |
2811 | // Send initial parcel data | ||
2812 | Vector3 pos = sp.AbsolutePosition; | ||
2813 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2814 | land.SendLandUpdateToClient(client); | ||
2815 | } | ||
2685 | 2816 | ||
2686 | return sp; | 2817 | return sp; |
2687 | } | 2818 | } |
@@ -2771,19 +2902,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2771 | // and the scene presence and the client, if they exist | 2902 | // and the scene presence and the client, if they exist |
2772 | try | 2903 | try |
2773 | { | 2904 | { |
2774 | // We need to wait for the client to make UDP contact first. | 2905 | ScenePresence sp = GetScenePresence(agentID); |
2775 | // It's the UDP contact that creates the scene presence | 2906 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2776 | ScenePresence sp = WaitGetScenePresence(agentID); | 2907 | |
2777 | if (sp != null) | 2908 | if (sp != null) |
2778 | { | ||
2779 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2780 | |||
2781 | sp.ControllingClient.Close(); | 2909 | sp.ControllingClient.Close(); |
2782 | } | 2910 | |
2783 | else | ||
2784 | { | ||
2785 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2786 | } | ||
2787 | // BANG! SLASH! | 2911 | // BANG! SLASH! |
2788 | m_authenticateHandler.RemoveCircuit(agentID); | 2912 | m_authenticateHandler.RemoveCircuit(agentID); |
2789 | 2913 | ||
@@ -2828,6 +2952,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2828 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2952 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2829 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2953 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2830 | 2954 | ||
2955 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2956 | |||
2831 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2957 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2832 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2958 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2833 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2959 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2884,6 +3010,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2884 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3010 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2885 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3011 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2886 | client.OnCopyInventoryItem += CopyInventoryItem; | 3012 | client.OnCopyInventoryItem += CopyInventoryItem; |
3013 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2887 | client.OnMoveInventoryItem += MoveInventoryItem; | 3014 | client.OnMoveInventoryItem += MoveInventoryItem; |
2888 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3015 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2889 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3016 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2955,6 +3082,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2955 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3082 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2956 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3083 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2957 | 3084 | ||
3085 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3086 | |||
2958 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3087 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2959 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3088 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2960 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3089 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3057,15 +3186,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3057 | /// </summary> | 3186 | /// </summary> |
3058 | /// <param name="agentId">The avatar's Unique ID</param> | 3187 | /// <param name="agentId">The avatar's Unique ID</param> |
3059 | /// <param name="client">The IClientAPI for the client</param> | 3188 | /// <param name="client">The IClientAPI for the client</param> |
3060 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3189 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3061 | { | 3190 | { |
3062 | if (m_teleportModule != null) | 3191 | if (m_teleportModule != null) |
3063 | m_teleportModule.TeleportHome(agentId, client); | 3192 | return m_teleportModule.TeleportHome(agentId, client); |
3064 | else | 3193 | else |
3065 | { | 3194 | { |
3066 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3195 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3067 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3196 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3068 | } | 3197 | } |
3198 | return false; | ||
3069 | } | 3199 | } |
3070 | 3200 | ||
3071 | /// <summary> | 3201 | /// <summary> |
@@ -3175,6 +3305,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3175 | /// <param name="flags"></param> | 3305 | /// <param name="flags"></param> |
3176 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3306 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3177 | { | 3307 | { |
3308 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3309 | ScenePresence presence; | ||
3310 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3311 | { | ||
3312 | if (presence.Appearance != null) | ||
3313 | { | ||
3314 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3315 | } | ||
3316 | } | ||
3317 | |||
3178 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3318 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3179 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3319 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3180 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3320 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3243,8 +3383,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3243 | regions.Remove(RegionInfo.RegionHandle); | 3383 | regions.Remove(RegionInfo.RegionHandle); |
3244 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3384 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3245 | } | 3385 | } |
3246 | 3386 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3247 | m_eventManager.TriggerClientClosed(agentID, this); | 3387 | m_eventManager.TriggerClientClosed(agentID, this); |
3388 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3248 | } | 3389 | } |
3249 | catch (NullReferenceException) | 3390 | catch (NullReferenceException) |
3250 | { | 3391 | { |
@@ -3306,9 +3447,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3306 | { | 3447 | { |
3307 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3448 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3308 | } | 3449 | } |
3309 | 3450 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3310 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3451 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3311 | // CleanDroppedAttachments(); | 3452 | // CleanDroppedAttachments(); |
3453 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3312 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3454 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3313 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3455 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3314 | } | 3456 | } |
@@ -3430,13 +3572,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3430 | sp = null; | 3572 | sp = null; |
3431 | } | 3573 | } |
3432 | 3574 | ||
3433 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3434 | 3575 | ||
3435 | //On login test land permisions | 3576 | //On login test land permisions |
3436 | if (vialogin) | 3577 | if (vialogin) |
3437 | { | 3578 | { |
3438 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3579 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3580 | if (cache != null) | ||
3581 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3582 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3439 | { | 3583 | { |
3584 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3440 | return false; | 3585 | return false; |
3441 | } | 3586 | } |
3442 | } | 3587 | } |
@@ -3460,8 +3605,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3460 | 3605 | ||
3461 | try | 3606 | try |
3462 | { | 3607 | { |
3463 | if (!AuthorizeUser(agent, out reason)) | 3608 | // Always check estate if this is a login. Always |
3464 | return false; | 3609 | // check if banned regions are to be blacked out. |
3610 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3611 | { | ||
3612 | if (!AuthorizeUser(agent, out reason)) | ||
3613 | return false; | ||
3614 | } | ||
3465 | } | 3615 | } |
3466 | catch (Exception e) | 3616 | catch (Exception e) |
3467 | { | 3617 | { |
@@ -3587,6 +3737,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3587 | } | 3737 | } |
3588 | 3738 | ||
3589 | // Honor parcel landing type and position. | 3739 | // Honor parcel landing type and position. |
3740 | /* | ||
3741 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3590 | if (land != null) | 3742 | if (land != null) |
3591 | { | 3743 | { |
3592 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3744 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3594,26 +3746,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3594 | agent.startpos = land.LandData.UserLocation; | 3746 | agent.startpos = land.LandData.UserLocation; |
3595 | } | 3747 | } |
3596 | } | 3748 | } |
3749 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3597 | } | 3750 | } |
3598 | 3751 | ||
3599 | return true; | 3752 | return true; |
3600 | } | 3753 | } |
3601 | 3754 | ||
3602 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3755 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3603 | { | 3756 | { |
3604 | 3757 | reason = String.Empty; | |
3605 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3758 | if (Permissions.IsGod(agentID)) |
3606 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3759 | return true; |
3760 | |||
3761 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3762 | if (land == null) | ||
3763 | return false; | ||
3764 | |||
3765 | bool banned = land.IsBannedFromLand(agentID); | ||
3766 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3607 | 3767 | ||
3608 | if (banned || restricted) | 3768 | if (banned || restricted) |
3609 | { | 3769 | { |
3610 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3770 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3611 | if (nearestParcel != null) | 3771 | if (nearestParcel != null) |
3612 | { | 3772 | { |
3613 | //Move agent to nearest allowed | 3773 | //Move agent to nearest allowed |
3614 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3774 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3615 | agent.startpos.X = newPosition.X; | 3775 | posX = newPosition.X; |
3616 | agent.startpos.Y = newPosition.Y; | 3776 | posY = newPosition.Y; |
3617 | } | 3777 | } |
3618 | else | 3778 | else |
3619 | { | 3779 | { |
@@ -3675,7 +3835,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3675 | 3835 | ||
3676 | if (!m_strictAccessControl) return true; | 3836 | if (!m_strictAccessControl) return true; |
3677 | if (Permissions.IsGod(agent.AgentID)) return true; | 3837 | if (Permissions.IsGod(agent.AgentID)) return true; |
3678 | 3838 | ||
3679 | if (AuthorizationService != null) | 3839 | if (AuthorizationService != null) |
3680 | { | 3840 | { |
3681 | if (!AuthorizationService.IsAuthorizedForRegion( | 3841 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3690,7 +3850,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3690 | 3850 | ||
3691 | if (m_regInfo.EstateSettings != null) | 3851 | if (m_regInfo.EstateSettings != null) |
3692 | { | 3852 | { |
3693 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3853 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3694 | { | 3854 | { |
3695 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3855 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3696 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3856 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3882,6 +4042,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3882 | 4042 | ||
3883 | // We have to wait until the viewer contacts this region after receiving EAC. | 4043 | // We have to wait until the viewer contacts this region after receiving EAC. |
3884 | // That calls AddNewClient, which finally creates the ScenePresence | 4044 | // That calls AddNewClient, which finally creates the ScenePresence |
4045 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4046 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4047 | { | ||
4048 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4049 | return false; | ||
4050 | } | ||
4051 | |||
3885 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4052 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3886 | if (nearestParcel == null) | 4053 | if (nearestParcel == null) |
3887 | { | 4054 | { |
@@ -3963,12 +4130,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3963 | return false; | 4130 | return false; |
3964 | } | 4131 | } |
3965 | 4132 | ||
4133 | public bool IncomingCloseAgent(UUID agentID) | ||
4134 | { | ||
4135 | return IncomingCloseAgent(agentID, false); | ||
4136 | } | ||
4137 | |||
4138 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4139 | { | ||
4140 | return IncomingCloseAgent(agentID, true); | ||
4141 | } | ||
4142 | |||
3966 | /// <summary> | 4143 | /// <summary> |
3967 | /// Tell a single agent to disconnect from the region. | 4144 | /// Tell a single agent to disconnect from the region. |
3968 | /// </summary> | 4145 | /// </summary> |
3969 | /// <param name="regionHandle"></param> | ||
3970 | /// <param name="agentID"></param> | 4146 | /// <param name="agentID"></param> |
3971 | public bool IncomingCloseAgent(UUID agentID) | 4147 | /// <param name="childOnly"></param> |
4148 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3972 | { | 4149 | { |
3973 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4150 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3974 | 4151 | ||
@@ -3980,7 +4157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3980 | { | 4157 | { |
3981 | m_sceneGraph.removeUserCount(false); | 4158 | m_sceneGraph.removeUserCount(false); |
3982 | } | 4159 | } |
3983 | else | 4160 | else if (!childOnly) |
3984 | { | 4161 | { |
3985 | m_sceneGraph.removeUserCount(true); | 4162 | m_sceneGraph.removeUserCount(true); |
3986 | } | 4163 | } |
@@ -3996,9 +4173,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3996 | } | 4173 | } |
3997 | else | 4174 | else |
3998 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4175 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4176 | presence.ControllingClient.Close(false); | ||
4177 | } | ||
4178 | else if (!childOnly) | ||
4179 | { | ||
4180 | presence.ControllingClient.Close(true); | ||
3999 | } | 4181 | } |
4000 | |||
4001 | presence.ControllingClient.Close(); | ||
4002 | return true; | 4182 | return true; |
4003 | } | 4183 | } |
4004 | 4184 | ||
@@ -4580,35 +4760,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4580 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4760 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4581 | } | 4761 | } |
4582 | 4762 | ||
4583 | public int GetHealth() | 4763 | public int GetHealth(out int flags, out string message) |
4584 | { | 4764 | { |
4585 | // Returns: | 4765 | // Returns: |
4586 | // 1 = sim is up and accepting http requests. The heartbeat has | 4766 | // 1 = sim is up and accepting http requests. The heartbeat has |
4587 | // stopped and the sim is probably locked up, but a remote | 4767 | // stopped and the sim is probably locked up, but a remote |
4588 | // admin restart may succeed | 4768 | // admin restart may succeed |
4589 | // | 4769 | // |
4590 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4770 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4591 | // usable for people within and logins _may_ work | 4771 | // usable for people within |
4772 | // | ||
4773 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4774 | // unstable and will not accept new logins | ||
4592 | // | 4775 | // |
4593 | // 3 = We have seen a new user enter within the past 4 minutes | 4776 | // 4 = Sim is up and both packet threads are running. Sim is |
4777 | // likely usable | ||
4778 | // | ||
4779 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4594 | // which can be seen as positive confirmation of sim health | 4780 | // which can be seen as positive confirmation of sim health |
4595 | // | 4781 | // |
4782 | |||
4783 | flags = 0; | ||
4784 | message = String.Empty; | ||
4785 | |||
4786 | CheckHeartbeat(); | ||
4787 | |||
4788 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4789 | { | ||
4790 | // We're still starting | ||
4791 | // 0 means "in startup", it can't happen another way, since | ||
4792 | // to get here, we must be able to accept http connections | ||
4793 | return 0; | ||
4794 | } | ||
4795 | |||
4596 | int health=1; // Start at 1, means we're up | 4796 | int health=1; // Start at 1, means we're up |
4597 | 4797 | ||
4598 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4798 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4599 | health += 1; | 4799 | { |
4800 | health+=1; | ||
4801 | flags |= 1; | ||
4802 | } | ||
4803 | |||
4804 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4805 | { | ||
4806 | health+=1; | ||
4807 | flags |= 2; | ||
4808 | } | ||
4809 | |||
4810 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4811 | { | ||
4812 | health+=1; | ||
4813 | flags |= 4; | ||
4814 | } | ||
4600 | else | 4815 | else |
4816 | { | ||
4817 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4818 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4819 | proc.EnableRaisingEvents=false; | ||
4820 | proc.StartInfo.FileName = "/bin/kill"; | ||
4821 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4822 | proc.Start(); | ||
4823 | proc.WaitForExit(); | ||
4824 | Thread.Sleep(1000); | ||
4825 | Environment.Exit(1); | ||
4826 | } | ||
4827 | |||
4828 | if (flags != 7) | ||
4601 | return health; | 4829 | return health; |
4602 | 4830 | ||
4603 | // A login in the last 4 mins? We can't be doing too badly | 4831 | // A login in the last 4 mins? We can't be doing too badly |
4604 | // | 4832 | // |
4605 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4833 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4606 | health++; | 4834 | health++; |
4607 | else | 4835 | else |
4608 | return health; | 4836 | return health; |
4609 | 4837 | ||
4610 | // CheckHeartbeat(); | ||
4611 | |||
4612 | return health; | 4838 | return health; |
4613 | } | 4839 | } |
4614 | 4840 | ||
@@ -4696,7 +4922,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4696 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4922 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4697 | if (wasUsingPhysics) | 4923 | if (wasUsingPhysics) |
4698 | { | 4924 | { |
4699 | 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 | 4925 | 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 |
4700 | } | 4926 | } |
4701 | } | 4927 | } |
4702 | 4928 | ||
@@ -4795,14 +5021,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4795 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5021 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4796 | } | 5022 | } |
4797 | 5023 | ||
4798 | // private void CheckHeartbeat() | 5024 | private void CheckHeartbeat() |
4799 | // { | 5025 | { |
4800 | // if (m_firstHeartbeat) | 5026 | if (m_firstHeartbeat) |
4801 | // return; | 5027 | return; |
4802 | // | 5028 | |
4803 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5029 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4804 | // StartTimer(); | 5030 | Start(); |
4805 | // } | 5031 | } |
4806 | 5032 | ||
4807 | public override ISceneObject DeserializeObject(string representation) | 5033 | public override ISceneObject DeserializeObject(string representation) |
4808 | { | 5034 | { |
@@ -4814,9 +5040,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4814 | get { return m_allowScriptCrossings; } | 5040 | get { return m_allowScriptCrossings; } |
4815 | } | 5041 | } |
4816 | 5042 | ||
4817 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5043 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5044 | { | ||
5045 | return GetNearestAllowedPosition(avatar, null); | ||
5046 | } | ||
5047 | |||
5048 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4818 | { | 5049 | { |
4819 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5050 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4820 | 5051 | ||
4821 | if (nearestParcel != null) | 5052 | if (nearestParcel != null) |
4822 | { | 5053 | { |
@@ -4825,10 +5056,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4825 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5056 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4826 | if (nearestPoint != null) | 5057 | if (nearestPoint != null) |
4827 | { | 5058 | { |
4828 | // m_log.DebugFormat( | 5059 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4829 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4830 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4831 | |||
4832 | return nearestPoint.Value; | 5060 | return nearestPoint.Value; |
4833 | } | 5061 | } |
4834 | 5062 | ||
@@ -4838,17 +5066,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4838 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5066 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4839 | if (nearestPoint != null) | 5067 | if (nearestPoint != null) |
4840 | { | 5068 | { |
4841 | // m_log.DebugFormat( | 5069 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4842 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4843 | |||
4844 | return nearestPoint.Value; | 5070 | return nearestPoint.Value; |
4845 | } | 5071 | } |
4846 | 5072 | ||
4847 | //Ultimate backup if we have no idea where they are | 5073 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4848 | // m_log.DebugFormat( | 5074 | if (dest != excludeParcel) |
4849 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5075 | { |
5076 | // Ultimate backup if we have no idea where they are and | ||
5077 | // the last allowed position was in another parcel | ||
5078 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5079 | return avatar.lastKnownAllowedPosition; | ||
5080 | } | ||
4850 | 5081 | ||
4851 | return avatar.lastKnownAllowedPosition; | 5082 | // else fall through to region edge |
4852 | } | 5083 | } |
4853 | 5084 | ||
4854 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5085 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4882,13 +5113,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4882 | 5113 | ||
4883 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5114 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4884 | { | 5115 | { |
5116 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5117 | } | ||
5118 | |||
5119 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5120 | { | ||
4885 | List<ILandObject> all = AllParcels(); | 5121 | List<ILandObject> all = AllParcels(); |
4886 | float minParcelDistance = float.MaxValue; | 5122 | float minParcelDistance = float.MaxValue; |
4887 | ILandObject nearestParcel = null; | 5123 | ILandObject nearestParcel = null; |
4888 | 5124 | ||
4889 | foreach (var parcel in all) | 5125 | foreach (var parcel in all) |
4890 | { | 5126 | { |
4891 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5127 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4892 | { | 5128 | { |
4893 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5129 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4894 | if (parcelDistance < minParcelDistance) | 5130 | if (parcelDistance < minParcelDistance) |
@@ -5130,7 +5366,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5130 | mapModule.GenerateMaptile(); | 5366 | mapModule.GenerateMaptile(); |
5131 | } | 5367 | } |
5132 | 5368 | ||
5133 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5369 | // public void CleanDroppedAttachments() |
5370 | // { | ||
5371 | // List<SceneObjectGroup> objectsToDelete = | ||
5372 | // new List<SceneObjectGroup>(); | ||
5373 | // | ||
5374 | // lock (m_cleaningAttachments) | ||
5375 | // { | ||
5376 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5377 | // { | ||
5378 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5379 | // { | ||
5380 | // UUID agentID = grp.OwnerID; | ||
5381 | // if (agentID == UUID.Zero) | ||
5382 | // { | ||
5383 | // objectsToDelete.Add(grp); | ||
5384 | // return; | ||
5385 | // } | ||
5386 | // | ||
5387 | // ScenePresence sp = GetScenePresence(agentID); | ||
5388 | // if (sp == null) | ||
5389 | // { | ||
5390 | // objectsToDelete.Add(grp); | ||
5391 | // return; | ||
5392 | // } | ||
5393 | // } | ||
5394 | // }); | ||
5395 | // } | ||
5396 | // | ||
5397 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5398 | // { | ||
5399 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5400 | // DeleteSceneObject(grp, true); | ||
5401 | // } | ||
5402 | // } | ||
5403 | |||
5404 | public void ThreadAlive(int threadCode) | ||
5405 | { | ||
5406 | switch(threadCode) | ||
5407 | { | ||
5408 | case 1: // Incoming | ||
5409 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5410 | break; | ||
5411 | case 2: // Incoming | ||
5412 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5413 | break; | ||
5414 | } | ||
5415 | } | ||
5416 | |||
5417 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5134 | { | 5418 | { |
5135 | RegenerateMaptile(); | 5419 | RegenerateMaptile(); |
5136 | 5420 | ||
@@ -5149,6 +5433,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5149 | // child agent creation, thereby emulating the SL behavior. | 5433 | // child agent creation, thereby emulating the SL behavior. |
5150 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5434 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5151 | { | 5435 | { |
5436 | reason = "You are banned from the region"; | ||
5437 | |||
5438 | if (Permissions.IsGod(agentID)) | ||
5439 | { | ||
5440 | reason = String.Empty; | ||
5441 | return true; | ||
5442 | } | ||
5443 | |||
5152 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5444 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5153 | 5445 | ||
5154 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5446 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5160,6 +5452,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5160 | } | 5452 | } |
5161 | } | 5453 | } |
5162 | 5454 | ||
5455 | ScenePresence presence = GetScenePresence(agentID); | ||
5456 | IClientAPI client = null; | ||
5457 | AgentCircuitData aCircuit = null; | ||
5458 | |||
5459 | if (presence != null) | ||
5460 | { | ||
5461 | client = presence.ControllingClient; | ||
5462 | if (client != null) | ||
5463 | aCircuit = client.RequestClientInfo(); | ||
5464 | } | ||
5465 | |||
5466 | // We may be called before there is a presence or a client. | ||
5467 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5468 | if (client == null) | ||
5469 | { | ||
5470 | aCircuit = new AgentCircuitData(); | ||
5471 | aCircuit.AgentID = agentID; | ||
5472 | aCircuit.firstname = String.Empty; | ||
5473 | aCircuit.lastname = String.Empty; | ||
5474 | } | ||
5475 | |||
5476 | try | ||
5477 | { | ||
5478 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5479 | { | ||
5480 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5481 | return false; | ||
5482 | } | ||
5483 | } | ||
5484 | catch (Exception e) | ||
5485 | { | ||
5486 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5487 | return false; | ||
5488 | } | ||
5489 | |||
5163 | if (position == Vector3.Zero) // Teleport | 5490 | if (position == Vector3.Zero) // Teleport |
5164 | { | 5491 | { |
5165 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5492 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5188,13 +5515,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5188 | } | 5515 | } |
5189 | } | 5516 | } |
5190 | } | 5517 | } |
5518 | |||
5519 | float posX = 128.0f; | ||
5520 | float posY = 128.0f; | ||
5521 | |||
5522 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5523 | { | ||
5524 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5525 | return false; | ||
5526 | } | ||
5527 | } | ||
5528 | else // Walking | ||
5529 | { | ||
5530 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5531 | if (land == null) | ||
5532 | return false; | ||
5533 | |||
5534 | bool banned = land.IsBannedFromLand(agentID); | ||
5535 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5536 | |||
5537 | if (banned || restricted) | ||
5538 | return false; | ||
5191 | } | 5539 | } |
5192 | 5540 | ||
5193 | reason = String.Empty; | 5541 | reason = String.Empty; |
5194 | return true; | 5542 | return true; |
5195 | } | 5543 | } |
5196 | 5544 | ||
5197 | /// <summary> | 5545 | public void StartTimerWatchdog() |
5546 | { | ||
5547 | m_timerWatchdog.Interval = 1000; | ||
5548 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5549 | m_timerWatchdog.AutoReset = true; | ||
5550 | m_timerWatchdog.Start(); | ||
5551 | } | ||
5552 | |||
5553 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5554 | { | ||
5555 | CheckHeartbeat(); | ||
5556 | } | ||
5557 | |||
5198 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5558 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5199 | /// autopilot that moves an avatar to a sit target!. | 5559 | /// autopilot that moves an avatar to a sit target!. |
5200 | /// </summary> | 5560 | /// </summary> |