diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 676 |
1 files changed, 518 insertions, 158 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 790ec63..44ee453 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -104,6 +104,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | // TODO: need to figure out how allow client agents but deny | 104 | // TODO: need to figure out how allow client agents but deny |
105 | // root agents when ACL denies access to root agent | 105 | // root agents when ACL denies access to root agent |
106 | public bool m_strictAccessControl = true; | 106 | public bool m_strictAccessControl = true; |
107 | public bool m_seeIntoBannedRegion = false; | ||
107 | public int MaxUndoCount = 5; | 108 | public int MaxUndoCount = 5; |
108 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 109 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
109 | public bool LoginLock = false; | 110 | public bool LoginLock = false; |
@@ -119,12 +120,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
119 | 120 | ||
120 | protected int m_splitRegionID; | 121 | protected int m_splitRegionID; |
121 | protected Timer m_restartWaitTimer = new Timer(); | 122 | protected Timer m_restartWaitTimer = new Timer(); |
123 | protected Timer m_timerWatchdog = new Timer(); | ||
122 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 124 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
123 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 125 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
124 | protected string m_simulatorVersion = "OpenSimulator Server"; | 126 | protected string m_simulatorVersion = "OpenSimulator Server"; |
125 | protected ModuleLoader m_moduleLoader; | 127 | protected ModuleLoader m_moduleLoader; |
126 | protected AgentCircuitManager m_authenticateHandler; | 128 | protected AgentCircuitManager m_authenticateHandler; |
127 | protected SceneCommunicationService m_sceneGridService; | 129 | protected SceneCommunicationService m_sceneGridService; |
130 | protected ISnmpModule m_snmpService = null; | ||
128 | 131 | ||
129 | protected ISimulationDataService m_SimulationDataService; | 132 | protected ISimulationDataService m_SimulationDataService; |
130 | protected IEstateDataService m_EstateDataService; | 133 | protected IEstateDataService m_EstateDataService; |
@@ -177,7 +180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
177 | private int m_update_events = 1; | 180 | private int m_update_events = 1; |
178 | private int m_update_backup = 200; | 181 | private int m_update_backup = 200; |
179 | private int m_update_terrain = 50; | 182 | private int m_update_terrain = 50; |
180 | // private int m_update_land = 1; | 183 | private int m_update_land = 10; |
181 | private int m_update_coarse_locations = 50; | 184 | private int m_update_coarse_locations = 50; |
182 | 185 | ||
183 | private int agentMS; | 186 | private int agentMS; |
@@ -196,6 +199,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
196 | /// </summary> | 199 | /// </summary> |
197 | private int m_lastFrameTick; | 200 | private int m_lastFrameTick; |
198 | 201 | ||
202 | public bool CombineRegions = false; | ||
199 | /// <summary> | 203 | /// <summary> |
200 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 204 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
201 | /// asynchronously from the update loop. | 205 | /// asynchronously from the update loop. |
@@ -218,12 +222,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
218 | private bool m_scripts_enabled = true; | 222 | private bool m_scripts_enabled = true; |
219 | private string m_defaultScriptEngine; | 223 | private string m_defaultScriptEngine; |
220 | private int m_LastLogin; | 224 | private int m_LastLogin; |
221 | private Thread HeartbeatThread; | 225 | private Thread HeartbeatThread = null; |
222 | private volatile bool shuttingdown; | 226 | private volatile bool shuttingdown; |
223 | 227 | ||
224 | private int m_lastUpdate; | 228 | private int m_lastUpdate; |
229 | private int m_lastIncoming; | ||
230 | private int m_lastOutgoing; | ||
225 | private bool m_firstHeartbeat = true; | 231 | private bool m_firstHeartbeat = true; |
226 | 232 | private int m_hbRestarts = 0; | |
233 | |||
227 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 234 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
228 | private bool m_reprioritizationEnabled = true; | 235 | private bool m_reprioritizationEnabled = true; |
229 | private double m_reprioritizationInterval = 5000.0; | 236 | private double m_reprioritizationInterval = 5000.0; |
@@ -267,6 +274,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | get { return m_sceneGridService; } | 274 | get { return m_sceneGridService; } |
268 | } | 275 | } |
269 | 276 | ||
277 | public ISnmpModule SnmpService | ||
278 | { | ||
279 | get | ||
280 | { | ||
281 | if (m_snmpService == null) | ||
282 | { | ||
283 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
284 | } | ||
285 | |||
286 | return m_snmpService; | ||
287 | } | ||
288 | } | ||
289 | |||
270 | public ISimulationDataService SimulationDataService | 290 | public ISimulationDataService SimulationDataService |
271 | { | 291 | { |
272 | get | 292 | get |
@@ -548,6 +568,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
548 | m_EstateDataService = estateDataService; | 568 | m_EstateDataService = estateDataService; |
549 | m_regionHandle = m_regInfo.RegionHandle; | 569 | m_regionHandle = m_regInfo.RegionHandle; |
550 | m_regionName = m_regInfo.RegionName; | 570 | m_regionName = m_regInfo.RegionName; |
571 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
572 | m_lastIncoming = 0; | ||
573 | m_lastOutgoing = 0; | ||
551 | 574 | ||
552 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 575 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
553 | m_asyncSceneObjectDeleter.Enabled = true; | 576 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -632,96 +655,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
632 | 655 | ||
633 | // Region config overrides global config | 656 | // Region config overrides global config |
634 | // | 657 | // |
635 | if (m_config.Configs["Startup"] != null) | 658 | try |
636 | { | 659 | { |
637 | IConfig startupConfig = m_config.Configs["Startup"]; | 660 | if (m_config.Configs["Startup"] != null) |
661 | { | ||
662 | IConfig startupConfig = m_config.Configs["Startup"]; | ||
638 | 663 | ||
639 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | 664 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
640 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | 665 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
641 | if (!m_useBackup) | 666 | if (!m_useBackup) |
642 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 667 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
643 | 668 | ||
644 | //Animation states | 669 | //Animation states |
645 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 670 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
646 | 671 | ||
647 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); | 672 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
648 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | 673 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
649 | 674 | ||
650 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | 675 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
651 | if (RegionInfo.NonphysPrimMax > 0) | 676 | if (RegionInfo.NonphysPrimMax > 0) |
652 | { | 677 | { |
653 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 678 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
654 | } | 679 | } |
655 | 680 | ||
656 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 681 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
657 | 682 | ||
658 | if (RegionInfo.PhysPrimMax > 0) | 683 | if (RegionInfo.PhysPrimMax > 0) |
659 | { | 684 | { |
660 | m_maxPhys = RegionInfo.PhysPrimMax; | 685 | m_maxPhys = RegionInfo.PhysPrimMax; |
661 | } | 686 | } |
662 | 687 | ||
663 | // Here, if clamping is requested in either global or | 688 | // Here, if clamping is requested in either global or |
664 | // local config, it will be used | 689 | // local config, it will be used |
665 | // | 690 | // |
666 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | 691 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); |
667 | if (RegionInfo.ClampPrimSize) | 692 | if (RegionInfo.ClampPrimSize) |
668 | { | 693 | { |
669 | m_clampPrimSize = true; | 694 | m_clampPrimSize = true; |
670 | } | 695 | } |
671 | 696 | ||
672 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 697 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
673 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 698 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
674 | m_dontPersistBefore = | 699 | m_dontPersistBefore = |
675 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | 700 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); |
676 | m_dontPersistBefore *= 10000000; | 701 | m_dontPersistBefore *= 10000000; |
677 | m_persistAfter = | 702 | m_persistAfter = |
678 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | 703 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); |
679 | m_persistAfter *= 10000000; | 704 | m_persistAfter *= 10000000; |
680 | 705 | ||
681 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 706 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
707 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
682 | 708 | ||
683 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 709 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
684 | if (packetConfig != null) | 710 | if (packetConfig != null) |
685 | { | 711 | { |
686 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | 712 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
687 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | 713 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); |
688 | } | 714 | } |
689 | 715 | ||
690 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 716 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
717 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
718 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
691 | 719 | ||
692 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 720 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
693 | if (m_generateMaptiles) | 721 | if (m_generateMaptiles) |
694 | { | ||
695 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | ||
696 | if (maptileRefresh != 0) | ||
697 | { | 722 | { |
698 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 723 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
699 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | 724 | if (maptileRefresh != 0) |
700 | m_mapGenerationTimer.AutoReset = true; | 725 | { |
701 | m_mapGenerationTimer.Start(); | 726 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; |
727 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
728 | m_mapGenerationTimer.AutoReset = true; | ||
729 | m_mapGenerationTimer.Start(); | ||
730 | } | ||
702 | } | 731 | } |
703 | } | 732 | else |
704 | else | ||
705 | { | ||
706 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
707 | UUID tileID; | ||
708 | |||
709 | if (UUID.TryParse(tile, out tileID)) | ||
710 | { | 733 | { |
711 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 734 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); |
735 | UUID tileID; | ||
736 | |||
737 | if (UUID.TryParse(tile, out tileID)) | ||
738 | { | ||
739 | RegionInfo.RegionSettings.TerrainImageID = tileID; | ||
740 | } | ||
712 | } | 741 | } |
713 | } | ||
714 | 742 | ||
715 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 743 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
716 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 744 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); |
717 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 745 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); |
718 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 746 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); |
719 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 747 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); |
720 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | 748 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); |
721 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | 749 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); |
722 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | 750 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); |
723 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 751 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
724 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 752 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
753 | } | ||
754 | } | ||
755 | catch (Exception e) | ||
756 | { | ||
757 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
725 | } | 758 | } |
726 | 759 | ||
727 | #endregion Region Config | 760 | #endregion Region Config |
@@ -1130,7 +1163,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1130 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1163 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1131 | if (HeartbeatThread != null) | 1164 | if (HeartbeatThread != null) |
1132 | { | 1165 | { |
1166 | m_hbRestarts++; | ||
1167 | if(m_hbRestarts > 10) | ||
1168 | Environment.Exit(1); | ||
1169 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1170 | |||
1171 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1172 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1173 | //proc.EnableRaisingEvents=false; | ||
1174 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1175 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1176 | //proc.Start(); | ||
1177 | //proc.WaitForExit(); | ||
1178 | //Thread.Sleep(1000); | ||
1179 | //Environment.Exit(1); | ||
1133 | HeartbeatThread.Abort(); | 1180 | HeartbeatThread.Abort(); |
1181 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1134 | HeartbeatThread = null; | 1182 | HeartbeatThread = null; |
1135 | } | 1183 | } |
1136 | m_lastUpdate = Util.EnvironmentTickCount(); | 1184 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1184,9 +1232,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1184 | 1232 | ||
1185 | while (!shuttingdown) | 1233 | while (!shuttingdown) |
1186 | Update(-1); | 1234 | Update(-1); |
1187 | |||
1188 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1189 | m_firstHeartbeat = false; | ||
1190 | } | 1235 | } |
1191 | finally | 1236 | finally |
1192 | { | 1237 | { |
@@ -1387,9 +1432,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1387 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1432 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); |
1388 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1433 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1389 | 1434 | ||
1435 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1436 | m_firstHeartbeat = false; | ||
1437 | |||
1390 | if (maintc > 0) | 1438 | if (maintc > 0) |
1391 | Thread.Sleep(maintc); | 1439 | Thread.Sleep(maintc); |
1392 | 1440 | ||
1441 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1442 | m_firstHeartbeat = false; | ||
1443 | |||
1393 | // Optionally warn if a frame takes double the amount of time that it should. | 1444 | // Optionally warn if a frame takes double the amount of time that it should. |
1394 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) | 1445 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) |
1395 | // m_log.WarnFormat( | 1446 | // m_log.WarnFormat( |
@@ -1414,9 +1465,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1414 | 1465 | ||
1415 | private void CheckAtTargets() | 1466 | private void CheckAtTargets() |
1416 | { | 1467 | { |
1417 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1468 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1418 | lock (m_groupsWithTargets) | 1469 | lock (m_groupsWithTargets) |
1419 | objs = m_groupsWithTargets.Values; | 1470 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1420 | 1471 | ||
1421 | foreach (SceneObjectGroup entry in objs) | 1472 | foreach (SceneObjectGroup entry in objs) |
1422 | entry.checkAtTargets(); | 1473 | entry.checkAtTargets(); |
@@ -1497,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1497 | msg.fromAgentName = "Server"; | 1548 | msg.fromAgentName = "Server"; |
1498 | msg.dialog = (byte)19; // Object msg | 1549 | msg.dialog = (byte)19; // Object msg |
1499 | msg.fromGroup = false; | 1550 | msg.fromGroup = false; |
1500 | msg.offline = (byte)0; | 1551 | msg.offline = (byte)1; |
1501 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1552 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1502 | msg.Position = Vector3.Zero; | 1553 | msg.Position = Vector3.Zero; |
1503 | msg.RegionID = RegionInfo.RegionID.Guid; | 1554 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1735,14 +1786,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1735 | /// <returns></returns> | 1786 | /// <returns></returns> |
1736 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1787 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1737 | { | 1788 | { |
1789 | |||
1790 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1791 | Vector3 wpos = Vector3.Zero; | ||
1792 | // Check for water surface intersection from above | ||
1793 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1794 | { | ||
1795 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1796 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1797 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1798 | wpos.Z = wheight; | ||
1799 | } | ||
1800 | |||
1738 | Vector3 pos = Vector3.Zero; | 1801 | Vector3 pos = Vector3.Zero; |
1739 | if (RayEndIsIntersection == (byte)1) | 1802 | if (RayEndIsIntersection == (byte)1) |
1740 | { | 1803 | { |
1741 | pos = RayEnd; | 1804 | pos = RayEnd; |
1742 | return pos; | ||
1743 | } | 1805 | } |
1744 | 1806 | else if (RayTargetID != UUID.Zero) | |
1745 | if (RayTargetID != UUID.Zero) | ||
1746 | { | 1807 | { |
1747 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1808 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1748 | 1809 | ||
@@ -1764,7 +1825,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1764 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1825 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1765 | 1826 | ||
1766 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1827 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1767 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1828 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1768 | float ScaleOffset = 0.5f; | 1829 | float ScaleOffset = 0.5f; |
1769 | 1830 | ||
1770 | // If we hit something | 1831 | // If we hit something |
@@ -1787,13 +1848,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1787 | //pos.Z -= 0.25F; | 1848 | //pos.Z -= 0.25F; |
1788 | 1849 | ||
1789 | } | 1850 | } |
1790 | |||
1791 | return pos; | ||
1792 | } | 1851 | } |
1793 | else | 1852 | else |
1794 | { | 1853 | { |
1795 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1854 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1796 | |||
1797 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1855 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1798 | 1856 | ||
1799 | // Un-comment the following line to print the raytrace results to the console. | 1857 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1802,13 +1860,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1802 | if (ei.HitTF) | 1860 | if (ei.HitTF) |
1803 | { | 1861 | { |
1804 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1862 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1805 | } else | 1863 | } |
1864 | else | ||
1806 | { | 1865 | { |
1807 | // fall back to our stupid functionality | 1866 | // fall back to our stupid functionality |
1808 | pos = RayEnd; | 1867 | pos = RayEnd; |
1809 | } | 1868 | } |
1810 | |||
1811 | return pos; | ||
1812 | } | 1869 | } |
1813 | } | 1870 | } |
1814 | else | 1871 | else |
@@ -1819,8 +1876,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1819 | //increase height so its above the ground. | 1876 | //increase height so its above the ground. |
1820 | //should be getting the normal of the ground at the rez point and using that? | 1877 | //should be getting the normal of the ground at the rez point and using that? |
1821 | pos.Z += scale.Z / 2f; | 1878 | pos.Z += scale.Z / 2f; |
1822 | return pos; | 1879 | // return pos; |
1823 | } | 1880 | } |
1881 | |||
1882 | // check against posible water intercept | ||
1883 | if (wpos.Z > pos.Z) pos = wpos; | ||
1884 | return pos; | ||
1824 | } | 1885 | } |
1825 | 1886 | ||
1826 | 1887 | ||
@@ -1904,7 +1965,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1904 | public bool AddRestoredSceneObject( | 1965 | public bool AddRestoredSceneObject( |
1905 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1966 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1906 | { | 1967 | { |
1907 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1968 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1969 | if (result) | ||
1970 | sceneObject.IsDeleted = false; | ||
1971 | return result; | ||
1908 | } | 1972 | } |
1909 | 1973 | ||
1910 | /// <summary> | 1974 | /// <summary> |
@@ -1996,6 +2060,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1996 | /// </summary> | 2060 | /// </summary> |
1997 | public void DeleteAllSceneObjects() | 2061 | public void DeleteAllSceneObjects() |
1998 | { | 2062 | { |
2063 | DeleteAllSceneObjects(false); | ||
2064 | } | ||
2065 | |||
2066 | /// <summary> | ||
2067 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2068 | /// </summary> | ||
2069 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2070 | { | ||
2071 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1999 | lock (Entities) | 2072 | lock (Entities) |
2000 | { | 2073 | { |
2001 | EntityBase[] entities = Entities.GetEntities(); | 2074 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2004,11 +2077,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2004 | if (e is SceneObjectGroup) | 2077 | if (e is SceneObjectGroup) |
2005 | { | 2078 | { |
2006 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2079 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2007 | if (!sog.IsAttachment) | 2080 | if (sog != null && !sog.IsAttachment) |
2008 | DeleteSceneObject((SceneObjectGroup)e, false); | 2081 | { |
2082 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2083 | { | ||
2084 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2085 | } | ||
2086 | else | ||
2087 | { | ||
2088 | toReturn.Add((SceneObjectGroup)e); | ||
2089 | } | ||
2090 | } | ||
2009 | } | 2091 | } |
2010 | } | 2092 | } |
2011 | } | 2093 | } |
2094 | if (toReturn.Count > 0) | ||
2095 | { | ||
2096 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2097 | } | ||
2012 | } | 2098 | } |
2013 | 2099 | ||
2014 | /// <summary> | 2100 | /// <summary> |
@@ -2049,6 +2135,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2049 | } | 2135 | } |
2050 | 2136 | ||
2051 | group.DeleteGroupFromScene(silent); | 2137 | group.DeleteGroupFromScene(silent); |
2138 | if (!silent) | ||
2139 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2052 | 2140 | ||
2053 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2141 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2054 | } | 2142 | } |
@@ -2338,6 +2426,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2338 | 2426 | ||
2339 | if (newPosition != Vector3.Zero) | 2427 | if (newPosition != Vector3.Zero) |
2340 | newObject.RootPart.GroupPosition = newPosition; | 2428 | newObject.RootPart.GroupPosition = newPosition; |
2429 | if (newObject.RootPart.KeyframeMotion != null) | ||
2430 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2341 | 2431 | ||
2342 | if (!AddSceneObject(newObject)) | 2432 | if (!AddSceneObject(newObject)) |
2343 | { | 2433 | { |
@@ -2406,10 +2496,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2406 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2496 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2407 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2497 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2408 | { | 2498 | { |
2499 | if (sceneObject.OwnerID == UUID.Zero) | ||
2500 | { | ||
2501 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2502 | return false; | ||
2503 | } | ||
2504 | |||
2409 | // If the user is banned, we won't let any of their objects | 2505 | // If the user is banned, we won't let any of their objects |
2410 | // enter. Period. | 2506 | // enter. Period. |
2411 | // | 2507 | // |
2412 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2508 | int flags = GetUserFlags(sceneObject.OwnerID); |
2509 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2413 | { | 2510 | { |
2414 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2511 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2415 | 2512 | ||
@@ -2455,12 +2552,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2455 | } | 2552 | } |
2456 | else | 2553 | else |
2457 | { | 2554 | { |
2555 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2458 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2556 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2459 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2557 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2460 | } | 2558 | } |
2559 | if (sceneObject.OwnerID == UUID.Zero) | ||
2560 | { | ||
2561 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2562 | return false; | ||
2563 | } | ||
2461 | } | 2564 | } |
2462 | else | 2565 | else |
2463 | { | 2566 | { |
2567 | if (sceneObject.OwnerID == UUID.Zero) | ||
2568 | { | ||
2569 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2570 | return false; | ||
2571 | } | ||
2464 | AddRestoredSceneObject(sceneObject, true, false); | 2572 | AddRestoredSceneObject(sceneObject, true, false); |
2465 | 2573 | ||
2466 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2574 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2489,6 +2597,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2489 | return 2; // StateSource.PrimCrossing | 2597 | return 2; // StateSource.PrimCrossing |
2490 | } | 2598 | } |
2491 | 2599 | ||
2600 | public int GetUserFlags(UUID user) | ||
2601 | { | ||
2602 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2603 | /* | ||
2604 | ScenePresence sp; | ||
2605 | if (TryGetScenePresence(user, out sp)) | ||
2606 | { | ||
2607 | return sp.UserFlags; | ||
2608 | } | ||
2609 | else | ||
2610 | { | ||
2611 | */ | ||
2612 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2613 | if (uac == null) | ||
2614 | return 0; | ||
2615 | return uac.UserFlags; | ||
2616 | //} | ||
2617 | } | ||
2492 | #endregion | 2618 | #endregion |
2493 | 2619 | ||
2494 | #region Add/Remove Avatar Methods | 2620 | #region Add/Remove Avatar Methods |
@@ -2503,6 +2629,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2503 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2629 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2504 | 2630 | ||
2505 | CheckHeartbeat(); | 2631 | CheckHeartbeat(); |
2632 | ScenePresence presence; | ||
2506 | 2633 | ||
2507 | ScenePresence sp = GetScenePresence(client.AgentId); | 2634 | ScenePresence sp = GetScenePresence(client.AgentId); |
2508 | 2635 | ||
@@ -2551,7 +2678,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2551 | 2678 | ||
2552 | EventManager.TriggerOnNewClient(client); | 2679 | EventManager.TriggerOnNewClient(client); |
2553 | if (vialogin) | 2680 | if (vialogin) |
2681 | { | ||
2554 | EventManager.TriggerOnClientLogin(client); | 2682 | EventManager.TriggerOnClientLogin(client); |
2683 | // Send initial parcel data | ||
2684 | Vector3 pos = sp.AbsolutePosition; | ||
2685 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2686 | land.SendLandUpdateToClient(client); | ||
2687 | } | ||
2555 | 2688 | ||
2556 | return sp; | 2689 | return sp; |
2557 | } | 2690 | } |
@@ -2641,19 +2774,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2641 | // and the scene presence and the client, if they exist | 2774 | // and the scene presence and the client, if they exist |
2642 | try | 2775 | try |
2643 | { | 2776 | { |
2644 | // We need to wait for the client to make UDP contact first. | 2777 | ScenePresence sp = GetScenePresence(agentID); |
2645 | // It's the UDP contact that creates the scene presence | 2778 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2646 | ScenePresence sp = WaitGetScenePresence(agentID); | 2779 | |
2647 | if (sp != null) | 2780 | if (sp != null) |
2648 | { | ||
2649 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2650 | |||
2651 | sp.ControllingClient.Close(); | 2781 | sp.ControllingClient.Close(); |
2652 | } | 2782 | |
2653 | else | ||
2654 | { | ||
2655 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2656 | } | ||
2657 | // BANG! SLASH! | 2783 | // BANG! SLASH! |
2658 | m_authenticateHandler.RemoveCircuit(agentID); | 2784 | m_authenticateHandler.RemoveCircuit(agentID); |
2659 | 2785 | ||
@@ -2698,6 +2824,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2698 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2824 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2699 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2825 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2700 | 2826 | ||
2827 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2828 | |||
2701 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2829 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2702 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2830 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2703 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2831 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2754,6 +2882,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2754 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2882 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2755 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2883 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2756 | client.OnCopyInventoryItem += CopyInventoryItem; | 2884 | client.OnCopyInventoryItem += CopyInventoryItem; |
2885 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2757 | client.OnMoveInventoryItem += MoveInventoryItem; | 2886 | client.OnMoveInventoryItem += MoveInventoryItem; |
2758 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2887 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2759 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2888 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2825,6 +2954,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2825 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 2954 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2826 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 2955 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2827 | 2956 | ||
2957 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
2958 | |||
2828 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 2959 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2829 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 2960 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2830 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 2961 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2927,15 +3058,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2927 | /// </summary> | 3058 | /// </summary> |
2928 | /// <param name="agentId">The avatar's Unique ID</param> | 3059 | /// <param name="agentId">The avatar's Unique ID</param> |
2929 | /// <param name="client">The IClientAPI for the client</param> | 3060 | /// <param name="client">The IClientAPI for the client</param> |
2930 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3061 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2931 | { | 3062 | { |
2932 | if (m_teleportModule != null) | 3063 | if (m_teleportModule != null) |
2933 | m_teleportModule.TeleportHome(agentId, client); | 3064 | return m_teleportModule.TeleportHome(agentId, client); |
2934 | else | 3065 | else |
2935 | { | 3066 | { |
2936 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3067 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2937 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3068 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2938 | } | 3069 | } |
3070 | return false; | ||
2939 | } | 3071 | } |
2940 | 3072 | ||
2941 | /// <summary> | 3073 | /// <summary> |
@@ -3045,6 +3177,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3045 | /// <param name="flags"></param> | 3177 | /// <param name="flags"></param> |
3046 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3178 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3047 | { | 3179 | { |
3180 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3181 | ScenePresence presence; | ||
3182 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3183 | { | ||
3184 | if (presence.Appearance != null) | ||
3185 | { | ||
3186 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3187 | } | ||
3188 | } | ||
3189 | |||
3048 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3190 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3049 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3191 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3050 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3192 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3113,8 +3255,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3113 | regions.Remove(RegionInfo.RegionHandle); | 3255 | regions.Remove(RegionInfo.RegionHandle); |
3114 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3256 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3115 | } | 3257 | } |
3116 | 3258 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3117 | m_eventManager.TriggerClientClosed(agentID, this); | 3259 | m_eventManager.TriggerClientClosed(agentID, this); |
3260 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3118 | } | 3261 | } |
3119 | catch (NullReferenceException) | 3262 | catch (NullReferenceException) |
3120 | { | 3263 | { |
@@ -3176,9 +3319,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3176 | { | 3319 | { |
3177 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3320 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3178 | } | 3321 | } |
3179 | 3322 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3180 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3323 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3181 | // CleanDroppedAttachments(); | 3324 | // CleanDroppedAttachments(); |
3325 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3182 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3326 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3183 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3327 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3184 | } | 3328 | } |
@@ -3300,13 +3444,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3300 | sp = null; | 3444 | sp = null; |
3301 | } | 3445 | } |
3302 | 3446 | ||
3303 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3304 | 3447 | ||
3305 | //On login test land permisions | 3448 | //On login test land permisions |
3306 | if (vialogin) | 3449 | if (vialogin) |
3307 | { | 3450 | { |
3308 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3451 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3452 | if (cache != null) | ||
3453 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3454 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3309 | { | 3455 | { |
3456 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3310 | return false; | 3457 | return false; |
3311 | } | 3458 | } |
3312 | } | 3459 | } |
@@ -3330,8 +3477,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3330 | 3477 | ||
3331 | try | 3478 | try |
3332 | { | 3479 | { |
3333 | if (!AuthorizeUser(agent, out reason)) | 3480 | // Always check estate if this is a login. Always |
3334 | return false; | 3481 | // check if banned regions are to be blacked out. |
3482 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3483 | { | ||
3484 | if (!AuthorizeUser(agent, out reason)) | ||
3485 | return false; | ||
3486 | } | ||
3335 | } | 3487 | } |
3336 | catch (Exception e) | 3488 | catch (Exception e) |
3337 | { | 3489 | { |
@@ -3457,6 +3609,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3457 | } | 3609 | } |
3458 | 3610 | ||
3459 | // Honor parcel landing type and position. | 3611 | // Honor parcel landing type and position. |
3612 | /* | ||
3613 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3460 | if (land != null) | 3614 | if (land != null) |
3461 | { | 3615 | { |
3462 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3616 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3464,26 +3618,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3464 | agent.startpos = land.LandData.UserLocation; | 3618 | agent.startpos = land.LandData.UserLocation; |
3465 | } | 3619 | } |
3466 | } | 3620 | } |
3621 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3467 | } | 3622 | } |
3468 | 3623 | ||
3469 | return true; | 3624 | return true; |
3470 | } | 3625 | } |
3471 | 3626 | ||
3472 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3627 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3473 | { | 3628 | { |
3474 | 3629 | reason = String.Empty; | |
3475 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3630 | if (Permissions.IsGod(agentID)) |
3476 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3631 | return true; |
3632 | |||
3633 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3634 | if (land == null) | ||
3635 | return false; | ||
3636 | |||
3637 | bool banned = land.IsBannedFromLand(agentID); | ||
3638 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3477 | 3639 | ||
3478 | if (banned || restricted) | 3640 | if (banned || restricted) |
3479 | { | 3641 | { |
3480 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3642 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3481 | if (nearestParcel != null) | 3643 | if (nearestParcel != null) |
3482 | { | 3644 | { |
3483 | //Move agent to nearest allowed | 3645 | //Move agent to nearest allowed |
3484 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3646 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3485 | agent.startpos.X = newPosition.X; | 3647 | posX = newPosition.X; |
3486 | agent.startpos.Y = newPosition.Y; | 3648 | posY = newPosition.Y; |
3487 | } | 3649 | } |
3488 | else | 3650 | else |
3489 | { | 3651 | { |
@@ -3545,7 +3707,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3545 | 3707 | ||
3546 | if (!m_strictAccessControl) return true; | 3708 | if (!m_strictAccessControl) return true; |
3547 | if (Permissions.IsGod(agent.AgentID)) return true; | 3709 | if (Permissions.IsGod(agent.AgentID)) return true; |
3548 | 3710 | ||
3549 | if (AuthorizationService != null) | 3711 | if (AuthorizationService != null) |
3550 | { | 3712 | { |
3551 | if (!AuthorizationService.IsAuthorizedForRegion( | 3713 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3560,7 +3722,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3560 | 3722 | ||
3561 | if (m_regInfo.EstateSettings != null) | 3723 | if (m_regInfo.EstateSettings != null) |
3562 | { | 3724 | { |
3563 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3725 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3564 | { | 3726 | { |
3565 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3727 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3566 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3728 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3752,6 +3914,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3752 | 3914 | ||
3753 | // We have to wait until the viewer contacts this region after receiving EAC. | 3915 | // We have to wait until the viewer contacts this region after receiving EAC. |
3754 | // That calls AddNewClient, which finally creates the ScenePresence | 3916 | // That calls AddNewClient, which finally creates the ScenePresence |
3917 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3918 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3919 | { | ||
3920 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3921 | return false; | ||
3922 | } | ||
3923 | |||
3755 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3924 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3756 | if (nearestParcel == null) | 3925 | if (nearestParcel == null) |
3757 | { | 3926 | { |
@@ -3833,12 +4002,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3833 | return false; | 4002 | return false; |
3834 | } | 4003 | } |
3835 | 4004 | ||
4005 | public bool IncomingCloseAgent(UUID agentID) | ||
4006 | { | ||
4007 | return IncomingCloseAgent(agentID, false); | ||
4008 | } | ||
4009 | |||
4010 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4011 | { | ||
4012 | return IncomingCloseAgent(agentID, true); | ||
4013 | } | ||
4014 | |||
3836 | /// <summary> | 4015 | /// <summary> |
3837 | /// Tell a single agent to disconnect from the region. | 4016 | /// Tell a single agent to disconnect from the region. |
3838 | /// </summary> | 4017 | /// </summary> |
3839 | /// <param name="regionHandle"></param> | ||
3840 | /// <param name="agentID"></param> | 4018 | /// <param name="agentID"></param> |
3841 | public bool IncomingCloseAgent(UUID agentID) | 4019 | /// <param name="childOnly"></param> |
4020 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3842 | { | 4021 | { |
3843 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4022 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3844 | 4023 | ||
@@ -3850,7 +4029,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3850 | { | 4029 | { |
3851 | m_sceneGraph.removeUserCount(false); | 4030 | m_sceneGraph.removeUserCount(false); |
3852 | } | 4031 | } |
3853 | else | 4032 | else if (!childOnly) |
3854 | { | 4033 | { |
3855 | m_sceneGraph.removeUserCount(true); | 4034 | m_sceneGraph.removeUserCount(true); |
3856 | } | 4035 | } |
@@ -3866,9 +4045,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3866 | } | 4045 | } |
3867 | else | 4046 | else |
3868 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4047 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4048 | presence.ControllingClient.Close(false); | ||
4049 | } | ||
4050 | else if (!childOnly) | ||
4051 | { | ||
4052 | presence.ControllingClient.Close(true); | ||
3869 | } | 4053 | } |
3870 | |||
3871 | presence.ControllingClient.Close(); | ||
3872 | return true; | 4054 | return true; |
3873 | } | 4055 | } |
3874 | 4056 | ||
@@ -4450,34 +4632,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4450 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4632 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4451 | } | 4633 | } |
4452 | 4634 | ||
4453 | public int GetHealth() | 4635 | public int GetHealth(out int flags, out string message) |
4454 | { | 4636 | { |
4455 | // Returns: | 4637 | // Returns: |
4456 | // 1 = sim is up and accepting http requests. The heartbeat has | 4638 | // 1 = sim is up and accepting http requests. The heartbeat has |
4457 | // stopped and the sim is probably locked up, but a remote | 4639 | // stopped and the sim is probably locked up, but a remote |
4458 | // admin restart may succeed | 4640 | // admin restart may succeed |
4459 | // | 4641 | // |
4460 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4642 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4461 | // usable for people within and logins _may_ work | 4643 | // usable for people within |
4644 | // | ||
4645 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4646 | // unstable and will not accept new logins | ||
4647 | // | ||
4648 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4649 | // likely usable | ||
4462 | // | 4650 | // |
4463 | // 3 = We have seen a new user enter within the past 4 minutes | 4651 | // 5 = We have seen a new user enter within the past 4 minutes |
4464 | // which can be seen as positive confirmation of sim health | 4652 | // which can be seen as positive confirmation of sim health |
4465 | // | 4653 | // |
4654 | |||
4655 | flags = 0; | ||
4656 | message = String.Empty; | ||
4657 | |||
4658 | CheckHeartbeat(); | ||
4659 | |||
4660 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4661 | { | ||
4662 | // We're still starting | ||
4663 | // 0 means "in startup", it can't happen another way, since | ||
4664 | // to get here, we must be able to accept http connections | ||
4665 | return 0; | ||
4666 | } | ||
4667 | |||
4466 | int health=1; // Start at 1, means we're up | 4668 | int health=1; // Start at 1, means we're up |
4467 | 4669 | ||
4468 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4670 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4671 | { | ||
4469 | health+=1; | 4672 | health+=1; |
4673 | flags |= 1; | ||
4674 | } | ||
4675 | |||
4676 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4677 | { | ||
4678 | health+=1; | ||
4679 | flags |= 2; | ||
4680 | } | ||
4681 | |||
4682 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4683 | { | ||
4684 | health+=1; | ||
4685 | flags |= 4; | ||
4686 | } | ||
4470 | else | 4687 | else |
4688 | { | ||
4689 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4690 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4691 | proc.EnableRaisingEvents=false; | ||
4692 | proc.StartInfo.FileName = "/bin/kill"; | ||
4693 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4694 | proc.Start(); | ||
4695 | proc.WaitForExit(); | ||
4696 | Thread.Sleep(1000); | ||
4697 | Environment.Exit(1); | ||
4698 | } | ||
4699 | |||
4700 | if (flags != 7) | ||
4471 | return health; | 4701 | return health; |
4472 | 4702 | ||
4473 | // A login in the last 4 mins? We can't be doing too badly | 4703 | // A login in the last 4 mins? We can't be doing too badly |
4474 | // | 4704 | // |
4475 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4705 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4476 | health++; | 4706 | health++; |
4477 | else | ||
4478 | return health; | ||
4479 | |||
4480 | CheckHeartbeat(); | ||
4481 | 4707 | ||
4482 | return health; | 4708 | return health; |
4483 | } | 4709 | } |
@@ -4566,7 +4792,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4566 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4792 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4567 | if (wasUsingPhysics) | 4793 | if (wasUsingPhysics) |
4568 | { | 4794 | { |
4569 | 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 | 4795 | 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 |
4570 | } | 4796 | } |
4571 | } | 4797 | } |
4572 | 4798 | ||
@@ -4670,7 +4896,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4670 | if (m_firstHeartbeat) | 4896 | if (m_firstHeartbeat) |
4671 | return; | 4897 | return; |
4672 | 4898 | ||
4673 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4899 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4674 | StartTimer(); | 4900 | StartTimer(); |
4675 | } | 4901 | } |
4676 | 4902 | ||
@@ -4684,9 +4910,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4684 | get { return m_allowScriptCrossings; } | 4910 | get { return m_allowScriptCrossings; } |
4685 | } | 4911 | } |
4686 | 4912 | ||
4687 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 4913 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4688 | { | 4914 | { |
4689 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 4915 | return GetNearestAllowedPosition(avatar, null); |
4916 | } | ||
4917 | |||
4918 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4919 | { | ||
4920 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
4690 | 4921 | ||
4691 | if (nearestParcel != null) | 4922 | if (nearestParcel != null) |
4692 | { | 4923 | { |
@@ -4695,10 +4926,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4695 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4926 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4696 | if (nearestPoint != null) | 4927 | if (nearestPoint != null) |
4697 | { | 4928 | { |
4698 | // m_log.DebugFormat( | 4929 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4699 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4700 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4701 | |||
4702 | return nearestPoint.Value; | 4930 | return nearestPoint.Value; |
4703 | } | 4931 | } |
4704 | 4932 | ||
@@ -4708,17 +4936,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4708 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4936 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4709 | if (nearestPoint != null) | 4937 | if (nearestPoint != null) |
4710 | { | 4938 | { |
4711 | // m_log.DebugFormat( | 4939 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4712 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4713 | |||
4714 | return nearestPoint.Value; | 4940 | return nearestPoint.Value; |
4715 | } | 4941 | } |
4716 | 4942 | ||
4717 | //Ultimate backup if we have no idea where they are | 4943 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4718 | // m_log.DebugFormat( | 4944 | if (dest != excludeParcel) |
4719 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 4945 | { |
4946 | // Ultimate backup if we have no idea where they are and | ||
4947 | // the last allowed position was in another parcel | ||
4948 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
4949 | return avatar.lastKnownAllowedPosition; | ||
4950 | } | ||
4720 | 4951 | ||
4721 | return avatar.lastKnownAllowedPosition; | 4952 | // else fall through to region edge |
4722 | } | 4953 | } |
4723 | 4954 | ||
4724 | //Go to the edge, this happens in teleporting to a region with no available parcels | 4955 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4752,13 +4983,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4752 | 4983 | ||
4753 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 4984 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4754 | { | 4985 | { |
4986 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
4987 | } | ||
4988 | |||
4989 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
4990 | { | ||
4755 | List<ILandObject> all = AllParcels(); | 4991 | List<ILandObject> all = AllParcels(); |
4756 | float minParcelDistance = float.MaxValue; | 4992 | float minParcelDistance = float.MaxValue; |
4757 | ILandObject nearestParcel = null; | 4993 | ILandObject nearestParcel = null; |
4758 | 4994 | ||
4759 | foreach (var parcel in all) | 4995 | foreach (var parcel in all) |
4760 | { | 4996 | { |
4761 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 4997 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4762 | { | 4998 | { |
4763 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 4999 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4764 | if (parcelDistance < minParcelDistance) | 5000 | if (parcelDistance < minParcelDistance) |
@@ -5000,7 +5236,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5000 | mapModule.GenerateMaptile(); | 5236 | mapModule.GenerateMaptile(); |
5001 | } | 5237 | } |
5002 | 5238 | ||
5003 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5239 | // public void CleanDroppedAttachments() |
5240 | // { | ||
5241 | // List<SceneObjectGroup> objectsToDelete = | ||
5242 | // new List<SceneObjectGroup>(); | ||
5243 | // | ||
5244 | // lock (m_cleaningAttachments) | ||
5245 | // { | ||
5246 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5247 | // { | ||
5248 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5249 | // { | ||
5250 | // UUID agentID = grp.OwnerID; | ||
5251 | // if (agentID == UUID.Zero) | ||
5252 | // { | ||
5253 | // objectsToDelete.Add(grp); | ||
5254 | // return; | ||
5255 | // } | ||
5256 | // | ||
5257 | // ScenePresence sp = GetScenePresence(agentID); | ||
5258 | // if (sp == null) | ||
5259 | // { | ||
5260 | // objectsToDelete.Add(grp); | ||
5261 | // return; | ||
5262 | // } | ||
5263 | // } | ||
5264 | // }); | ||
5265 | // } | ||
5266 | // | ||
5267 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5268 | // { | ||
5269 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5270 | // DeleteSceneObject(grp, true); | ||
5271 | // } | ||
5272 | // } | ||
5273 | |||
5274 | public void ThreadAlive(int threadCode) | ||
5275 | { | ||
5276 | switch(threadCode) | ||
5277 | { | ||
5278 | case 1: // Incoming | ||
5279 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5280 | break; | ||
5281 | case 2: // Incoming | ||
5282 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5283 | break; | ||
5284 | } | ||
5285 | } | ||
5286 | |||
5287 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5004 | { | 5288 | { |
5005 | RegenerateMaptile(); | 5289 | RegenerateMaptile(); |
5006 | 5290 | ||
@@ -5019,6 +5303,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5019 | // child agent creation, thereby emulating the SL behavior. | 5303 | // child agent creation, thereby emulating the SL behavior. |
5020 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5304 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5021 | { | 5305 | { |
5306 | reason = "You are banned from the region"; | ||
5307 | |||
5308 | if (Permissions.IsGod(agentID)) | ||
5309 | { | ||
5310 | reason = String.Empty; | ||
5311 | return true; | ||
5312 | } | ||
5313 | |||
5022 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5314 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5023 | 5315 | ||
5024 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5316 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5030,6 +5322,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5030 | } | 5322 | } |
5031 | } | 5323 | } |
5032 | 5324 | ||
5325 | ScenePresence presence = GetScenePresence(agentID); | ||
5326 | IClientAPI client = null; | ||
5327 | AgentCircuitData aCircuit = null; | ||
5328 | |||
5329 | if (presence != null) | ||
5330 | { | ||
5331 | client = presence.ControllingClient; | ||
5332 | if (client != null) | ||
5333 | aCircuit = client.RequestClientInfo(); | ||
5334 | } | ||
5335 | |||
5336 | // We may be called before there is a presence or a client. | ||
5337 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5338 | if (client == null) | ||
5339 | { | ||
5340 | aCircuit = new AgentCircuitData(); | ||
5341 | aCircuit.AgentID = agentID; | ||
5342 | aCircuit.firstname = String.Empty; | ||
5343 | aCircuit.lastname = String.Empty; | ||
5344 | } | ||
5345 | |||
5346 | try | ||
5347 | { | ||
5348 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5349 | { | ||
5350 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5351 | return false; | ||
5352 | } | ||
5353 | } | ||
5354 | catch (Exception e) | ||
5355 | { | ||
5356 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5357 | return false; | ||
5358 | } | ||
5359 | |||
5033 | if (position == Vector3.Zero) // Teleport | 5360 | if (position == Vector3.Zero) // Teleport |
5034 | { | 5361 | { |
5035 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5362 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5058,13 +5385,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5058 | } | 5385 | } |
5059 | } | 5386 | } |
5060 | } | 5387 | } |
5388 | |||
5389 | float posX = 128.0f; | ||
5390 | float posY = 128.0f; | ||
5391 | |||
5392 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5393 | { | ||
5394 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5395 | return false; | ||
5396 | } | ||
5397 | } | ||
5398 | else // Walking | ||
5399 | { | ||
5400 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5401 | if (land == null) | ||
5402 | return false; | ||
5403 | |||
5404 | bool banned = land.IsBannedFromLand(agentID); | ||
5405 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5406 | |||
5407 | if (banned || restricted) | ||
5408 | return false; | ||
5061 | } | 5409 | } |
5062 | 5410 | ||
5063 | reason = String.Empty; | 5411 | reason = String.Empty; |
5064 | return true; | 5412 | return true; |
5065 | } | 5413 | } |
5066 | 5414 | ||
5067 | /// <summary> | 5415 | public void StartTimerWatchdog() |
5416 | { | ||
5417 | m_timerWatchdog.Interval = 1000; | ||
5418 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5419 | m_timerWatchdog.AutoReset = true; | ||
5420 | m_timerWatchdog.Start(); | ||
5421 | } | ||
5422 | |||
5423 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5424 | { | ||
5425 | CheckHeartbeat(); | ||
5426 | } | ||
5427 | |||
5068 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5428 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5069 | /// autopilot that moves an avatar to a sit target!. | 5429 | /// autopilot that moves an avatar to a sit target!. |
5070 | /// </summary> | 5430 | /// </summary> |