diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 683 |
1 files changed, 524 insertions, 159 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0706905..753effc 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; |
@@ -192,6 +195,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | private int landMS; | 195 | private int landMS; |
193 | private int lastCompletedFrame; | 196 | private int lastCompletedFrame; |
194 | 197 | ||
198 | public bool CombineRegions = false; | ||
195 | /// <summary> | 199 | /// <summary> |
196 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 200 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
197 | /// asynchronously from the update loop. | 201 | /// asynchronously from the update loop. |
@@ -214,12 +218,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | private bool m_scripts_enabled = true; | 218 | private bool m_scripts_enabled = true; |
215 | private string m_defaultScriptEngine; | 219 | private string m_defaultScriptEngine; |
216 | private int m_LastLogin; | 220 | private int m_LastLogin; |
217 | private Thread HeartbeatThread; | 221 | private Thread HeartbeatThread = null; |
218 | private volatile bool shuttingdown; | 222 | private volatile bool shuttingdown; |
219 | 223 | ||
220 | private int m_lastUpdate; | 224 | private int m_lastUpdate; |
225 | private int m_lastIncoming; | ||
226 | private int m_lastOutgoing; | ||
221 | private bool m_firstHeartbeat = true; | 227 | private bool m_firstHeartbeat = true; |
222 | 228 | private int m_hbRestarts = 0; | |
229 | |||
223 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 230 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
224 | private bool m_reprioritizationEnabled = true; | 231 | private bool m_reprioritizationEnabled = true; |
225 | private double m_reprioritizationInterval = 5000.0; | 232 | private double m_reprioritizationInterval = 5000.0; |
@@ -263,6 +270,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
263 | get { return m_sceneGridService; } | 270 | get { return m_sceneGridService; } |
264 | } | 271 | } |
265 | 272 | ||
273 | public ISnmpModule SnmpService | ||
274 | { | ||
275 | get | ||
276 | { | ||
277 | if (m_snmpService == null) | ||
278 | { | ||
279 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
280 | } | ||
281 | |||
282 | return m_snmpService; | ||
283 | } | ||
284 | } | ||
285 | |||
266 | public ISimulationDataService SimulationDataService | 286 | public ISimulationDataService SimulationDataService |
267 | { | 287 | { |
268 | get | 288 | get |
@@ -544,6 +564,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
544 | m_EstateDataService = estateDataService; | 564 | m_EstateDataService = estateDataService; |
545 | m_regionHandle = m_regInfo.RegionHandle; | 565 | m_regionHandle = m_regInfo.RegionHandle; |
546 | m_regionName = m_regInfo.RegionName; | 566 | m_regionName = m_regInfo.RegionName; |
567 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
568 | m_lastIncoming = 0; | ||
569 | m_lastOutgoing = 0; | ||
547 | 570 | ||
548 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 571 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
549 | m_asyncSceneObjectDeleter.Enabled = true; | 572 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -628,96 +651,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
628 | 651 | ||
629 | // Region config overrides global config | 652 | // Region config overrides global config |
630 | // | 653 | // |
631 | if (m_config.Configs["Startup"] != null) | 654 | try |
632 | { | 655 | { |
633 | IConfig startupConfig = m_config.Configs["Startup"]; | 656 | if (m_config.Configs["Startup"] != null) |
657 | { | ||
658 | IConfig startupConfig = m_config.Configs["Startup"]; | ||
634 | 659 | ||
635 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | 660 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
636 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | 661 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
637 | if (!m_useBackup) | 662 | if (!m_useBackup) |
638 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 663 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
639 | 664 | ||
640 | //Animation states | 665 | //Animation states |
641 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 666 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
642 | 667 | ||
643 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); | 668 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
644 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | 669 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
645 | 670 | ||
646 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | 671 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
647 | if (RegionInfo.NonphysPrimMax > 0) | 672 | if (RegionInfo.NonphysPrimMax > 0) |
648 | { | 673 | { |
649 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 674 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
650 | } | 675 | } |
651 | 676 | ||
652 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 677 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
653 | 678 | ||
654 | if (RegionInfo.PhysPrimMax > 0) | 679 | if (RegionInfo.PhysPrimMax > 0) |
655 | { | 680 | { |
656 | m_maxPhys = RegionInfo.PhysPrimMax; | 681 | m_maxPhys = RegionInfo.PhysPrimMax; |
657 | } | 682 | } |
658 | 683 | ||
659 | // Here, if clamping is requested in either global or | 684 | // Here, if clamping is requested in either global or |
660 | // local config, it will be used | 685 | // local config, it will be used |
661 | // | 686 | // |
662 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | 687 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); |
663 | if (RegionInfo.ClampPrimSize) | 688 | if (RegionInfo.ClampPrimSize) |
664 | { | 689 | { |
665 | m_clampPrimSize = true; | 690 | m_clampPrimSize = true; |
666 | } | 691 | } |
667 | 692 | ||
668 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 693 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
669 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 694 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
670 | m_dontPersistBefore = | 695 | m_dontPersistBefore = |
671 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | 696 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); |
672 | m_dontPersistBefore *= 10000000; | 697 | m_dontPersistBefore *= 10000000; |
673 | m_persistAfter = | 698 | m_persistAfter = |
674 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | 699 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); |
675 | m_persistAfter *= 10000000; | 700 | m_persistAfter *= 10000000; |
676 | 701 | ||
677 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 702 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
703 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
678 | 704 | ||
679 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 705 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
680 | if (packetConfig != null) | 706 | if (packetConfig != null) |
681 | { | 707 | { |
682 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | 708 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
683 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | 709 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); |
684 | } | 710 | } |
685 | 711 | ||
686 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 712 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
713 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
714 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
687 | 715 | ||
688 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 716 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
689 | if (m_generateMaptiles) | 717 | if (m_generateMaptiles) |
690 | { | ||
691 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | ||
692 | if (maptileRefresh != 0) | ||
693 | { | 718 | { |
694 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 719 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
695 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | 720 | if (maptileRefresh != 0) |
696 | m_mapGenerationTimer.AutoReset = true; | 721 | { |
697 | m_mapGenerationTimer.Start(); | 722 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; |
723 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
724 | m_mapGenerationTimer.AutoReset = true; | ||
725 | m_mapGenerationTimer.Start(); | ||
726 | } | ||
698 | } | 727 | } |
699 | } | 728 | else |
700 | else | ||
701 | { | ||
702 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
703 | UUID tileID; | ||
704 | |||
705 | if (UUID.TryParse(tile, out tileID)) | ||
706 | { | 729 | { |
707 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 730 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); |
731 | UUID tileID; | ||
732 | |||
733 | if (UUID.TryParse(tile, out tileID)) | ||
734 | { | ||
735 | RegionInfo.RegionSettings.TerrainImageID = tileID; | ||
736 | } | ||
708 | } | 737 | } |
709 | } | ||
710 | 738 | ||
711 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 739 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
712 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 740 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); |
713 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 741 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); |
714 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 742 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); |
715 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 743 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); |
716 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | 744 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); |
717 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | 745 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); |
718 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | 746 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); |
719 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 747 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
720 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 748 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
749 | } | ||
750 | } | ||
751 | catch (Exception e) | ||
752 | { | ||
753 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
721 | } | 754 | } |
722 | 755 | ||
723 | #endregion Region Config | 756 | #endregion Region Config |
@@ -1126,7 +1159,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1126 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1159 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1127 | if (HeartbeatThread != null) | 1160 | if (HeartbeatThread != null) |
1128 | { | 1161 | { |
1162 | m_hbRestarts++; | ||
1163 | if(m_hbRestarts > 10) | ||
1164 | Environment.Exit(1); | ||
1165 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1166 | |||
1167 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1168 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1169 | //proc.EnableRaisingEvents=false; | ||
1170 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1171 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1172 | //proc.Start(); | ||
1173 | //proc.WaitForExit(); | ||
1174 | //Thread.Sleep(1000); | ||
1175 | //Environment.Exit(1); | ||
1129 | HeartbeatThread.Abort(); | 1176 | HeartbeatThread.Abort(); |
1177 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1130 | HeartbeatThread = null; | 1178 | HeartbeatThread = null; |
1131 | } | 1179 | } |
1132 | m_lastUpdate = Util.EnvironmentTickCount(); | 1180 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1180,9 +1228,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1180 | 1228 | ||
1181 | while (!shuttingdown) | 1229 | while (!shuttingdown) |
1182 | Update(); | 1230 | Update(); |
1183 | |||
1184 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1185 | m_firstHeartbeat = false; | ||
1186 | } | 1231 | } |
1187 | catch (ThreadAbortException) | 1232 | catch (ThreadAbortException) |
1188 | { | 1233 | { |
@@ -1280,6 +1325,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1280 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1325 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1281 | } | 1326 | } |
1282 | 1327 | ||
1328 | // if (Frame % m_update_land == 0) | ||
1329 | // { | ||
1330 | // int ldMS = Util.EnvironmentTickCount(); | ||
1331 | // UpdateLand(); | ||
1332 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1333 | // } | ||
1334 | |||
1283 | if (Frame % m_update_backup == 0) | 1335 | if (Frame % m_update_backup == 0) |
1284 | { | 1336 | { |
1285 | int backMS = Util.EnvironmentTickCount(); | 1337 | int backMS = Util.EnvironmentTickCount(); |
@@ -1373,12 +1425,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1425 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1374 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1426 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1375 | 1427 | ||
1428 | |||
1429 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1430 | m_firstHeartbeat = false; | ||
1431 | |||
1376 | if (maintc > 0) | 1432 | if (maintc > 0) |
1377 | Thread.Sleep(maintc); | 1433 | Thread.Sleep(maintc); |
1378 | 1434 | ||
1379 | // Tell the watchdog that this thread is still alive | 1435 | // Tell the watchdog that this thread is still alive |
1380 | Watchdog.UpdateThread(); | 1436 | Watchdog.UpdateThread(); |
1381 | } | 1437 | } |
1382 | 1438 | ||
1383 | public void AddGroupTarget(SceneObjectGroup grp) | 1439 | public void AddGroupTarget(SceneObjectGroup grp) |
1384 | { | 1440 | { |
@@ -1394,9 +1450,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1394 | 1450 | ||
1395 | private void CheckAtTargets() | 1451 | private void CheckAtTargets() |
1396 | { | 1452 | { |
1397 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1453 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1398 | lock (m_groupsWithTargets) | 1454 | lock (m_groupsWithTargets) |
1399 | objs = m_groupsWithTargets.Values; | 1455 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1400 | 1456 | ||
1401 | foreach (SceneObjectGroup entry in objs) | 1457 | foreach (SceneObjectGroup entry in objs) |
1402 | entry.checkAtTargets(); | 1458 | entry.checkAtTargets(); |
@@ -1477,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1477 | msg.fromAgentName = "Server"; | 1533 | msg.fromAgentName = "Server"; |
1478 | msg.dialog = (byte)19; // Object msg | 1534 | msg.dialog = (byte)19; // Object msg |
1479 | msg.fromGroup = false; | 1535 | msg.fromGroup = false; |
1480 | msg.offline = (byte)0; | 1536 | msg.offline = (byte)1; |
1481 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1537 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1482 | msg.Position = Vector3.Zero; | 1538 | msg.Position = Vector3.Zero; |
1483 | msg.RegionID = RegionInfo.RegionID.Guid; | 1539 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1715,14 +1771,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1715 | /// <returns></returns> | 1771 | /// <returns></returns> |
1716 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1772 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1717 | { | 1773 | { |
1774 | |||
1775 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1776 | Vector3 wpos = Vector3.Zero; | ||
1777 | // Check for water surface intersection from above | ||
1778 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1779 | { | ||
1780 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1781 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1782 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1783 | wpos.Z = wheight; | ||
1784 | } | ||
1785 | |||
1718 | Vector3 pos = Vector3.Zero; | 1786 | Vector3 pos = Vector3.Zero; |
1719 | if (RayEndIsIntersection == (byte)1) | 1787 | if (RayEndIsIntersection == (byte)1) |
1720 | { | 1788 | { |
1721 | pos = RayEnd; | 1789 | pos = RayEnd; |
1722 | return pos; | ||
1723 | } | 1790 | } |
1724 | 1791 | else if (RayTargetID != UUID.Zero) | |
1725 | if (RayTargetID != UUID.Zero) | ||
1726 | { | 1792 | { |
1727 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1793 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1728 | 1794 | ||
@@ -1744,7 +1810,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1744 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1810 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1745 | 1811 | ||
1746 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1812 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1747 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1813 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1748 | float ScaleOffset = 0.5f; | 1814 | float ScaleOffset = 0.5f; |
1749 | 1815 | ||
1750 | // If we hit something | 1816 | // If we hit something |
@@ -1767,13 +1833,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1767 | //pos.Z -= 0.25F; | 1833 | //pos.Z -= 0.25F; |
1768 | 1834 | ||
1769 | } | 1835 | } |
1770 | |||
1771 | return pos; | ||
1772 | } | 1836 | } |
1773 | else | 1837 | else |
1774 | { | 1838 | { |
1775 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1839 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1776 | |||
1777 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1840 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1778 | 1841 | ||
1779 | // Un-comment the following line to print the raytrace results to the console. | 1842 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1782,13 +1845,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1782 | if (ei.HitTF) | 1845 | if (ei.HitTF) |
1783 | { | 1846 | { |
1784 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1847 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1785 | } else | 1848 | } |
1849 | else | ||
1786 | { | 1850 | { |
1787 | // fall back to our stupid functionality | 1851 | // fall back to our stupid functionality |
1788 | pos = RayEnd; | 1852 | pos = RayEnd; |
1789 | } | 1853 | } |
1790 | |||
1791 | return pos; | ||
1792 | } | 1854 | } |
1793 | } | 1855 | } |
1794 | else | 1856 | else |
@@ -1799,8 +1861,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1799 | //increase height so its above the ground. | 1861 | //increase height so its above the ground. |
1800 | //should be getting the normal of the ground at the rez point and using that? | 1862 | //should be getting the normal of the ground at the rez point and using that? |
1801 | pos.Z += scale.Z / 2f; | 1863 | pos.Z += scale.Z / 2f; |
1802 | return pos; | 1864 | // return pos; |
1803 | } | 1865 | } |
1866 | |||
1867 | // check against posible water intercept | ||
1868 | if (wpos.Z > pos.Z) pos = wpos; | ||
1869 | return pos; | ||
1804 | } | 1870 | } |
1805 | 1871 | ||
1806 | 1872 | ||
@@ -1884,7 +1950,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1884 | public bool AddRestoredSceneObject( | 1950 | public bool AddRestoredSceneObject( |
1885 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1951 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1886 | { | 1952 | { |
1887 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1953 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1954 | if (result) | ||
1955 | sceneObject.IsDeleted = false; | ||
1956 | return result; | ||
1888 | } | 1957 | } |
1889 | 1958 | ||
1890 | /// <summary> | 1959 | /// <summary> |
@@ -1976,6 +2045,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1976 | /// </summary> | 2045 | /// </summary> |
1977 | public void DeleteAllSceneObjects() | 2046 | public void DeleteAllSceneObjects() |
1978 | { | 2047 | { |
2048 | DeleteAllSceneObjects(false); | ||
2049 | } | ||
2050 | |||
2051 | /// <summary> | ||
2052 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2053 | /// </summary> | ||
2054 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2055 | { | ||
2056 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1979 | lock (Entities) | 2057 | lock (Entities) |
1980 | { | 2058 | { |
1981 | EntityBase[] entities = Entities.GetEntities(); | 2059 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1984,11 +2062,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1984 | if (e is SceneObjectGroup) | 2062 | if (e is SceneObjectGroup) |
1985 | { | 2063 | { |
1986 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2064 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1987 | if (!sog.IsAttachment) | 2065 | if (sog != null && !sog.IsAttachment) |
1988 | DeleteSceneObject((SceneObjectGroup)e, false); | 2066 | { |
2067 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2068 | { | ||
2069 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2070 | } | ||
2071 | else | ||
2072 | { | ||
2073 | toReturn.Add((SceneObjectGroup)e); | ||
2074 | } | ||
2075 | } | ||
1989 | } | 2076 | } |
1990 | } | 2077 | } |
1991 | } | 2078 | } |
2079 | if (toReturn.Count > 0) | ||
2080 | { | ||
2081 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2082 | } | ||
1992 | } | 2083 | } |
1993 | 2084 | ||
1994 | /// <summary> | 2085 | /// <summary> |
@@ -2029,6 +2120,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2029 | } | 2120 | } |
2030 | 2121 | ||
2031 | group.DeleteGroupFromScene(silent); | 2122 | group.DeleteGroupFromScene(silent); |
2123 | if (!silent) | ||
2124 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2032 | 2125 | ||
2033 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2126 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2034 | } | 2127 | } |
@@ -2318,6 +2411,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2318 | 2411 | ||
2319 | if (newPosition != Vector3.Zero) | 2412 | if (newPosition != Vector3.Zero) |
2320 | newObject.RootPart.GroupPosition = newPosition; | 2413 | newObject.RootPart.GroupPosition = newPosition; |
2414 | if (newObject.RootPart.KeyframeMotion != null) | ||
2415 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2321 | 2416 | ||
2322 | if (!AddSceneObject(newObject)) | 2417 | if (!AddSceneObject(newObject)) |
2323 | { | 2418 | { |
@@ -2386,10 +2481,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2386 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2481 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2387 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2482 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2388 | { | 2483 | { |
2484 | if (sceneObject.OwnerID == UUID.Zero) | ||
2485 | { | ||
2486 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2487 | return false; | ||
2488 | } | ||
2489 | |||
2389 | // If the user is banned, we won't let any of their objects | 2490 | // If the user is banned, we won't let any of their objects |
2390 | // enter. Period. | 2491 | // enter. Period. |
2391 | // | 2492 | // |
2392 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2493 | int flags = GetUserFlags(sceneObject.OwnerID); |
2494 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2393 | { | 2495 | { |
2394 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2496 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2395 | 2497 | ||
@@ -2435,12 +2537,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2435 | } | 2537 | } |
2436 | else | 2538 | else |
2437 | { | 2539 | { |
2540 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2438 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2541 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2439 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2542 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2440 | } | 2543 | } |
2544 | if (sceneObject.OwnerID == UUID.Zero) | ||
2545 | { | ||
2546 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2547 | return false; | ||
2548 | } | ||
2441 | } | 2549 | } |
2442 | else | 2550 | else |
2443 | { | 2551 | { |
2552 | if (sceneObject.OwnerID == UUID.Zero) | ||
2553 | { | ||
2554 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2555 | return false; | ||
2556 | } | ||
2444 | AddRestoredSceneObject(sceneObject, true, false); | 2557 | AddRestoredSceneObject(sceneObject, true, false); |
2445 | 2558 | ||
2446 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2559 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2469,6 +2582,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2469 | return 2; // StateSource.PrimCrossing | 2582 | return 2; // StateSource.PrimCrossing |
2470 | } | 2583 | } |
2471 | 2584 | ||
2585 | public int GetUserFlags(UUID user) | ||
2586 | { | ||
2587 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2588 | /* | ||
2589 | ScenePresence sp; | ||
2590 | if (TryGetScenePresence(user, out sp)) | ||
2591 | { | ||
2592 | return sp.UserFlags; | ||
2593 | } | ||
2594 | else | ||
2595 | { | ||
2596 | */ | ||
2597 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2598 | if (uac == null) | ||
2599 | return 0; | ||
2600 | return uac.UserFlags; | ||
2601 | //} | ||
2602 | } | ||
2472 | #endregion | 2603 | #endregion |
2473 | 2604 | ||
2474 | #region Add/Remove Avatar Methods | 2605 | #region Add/Remove Avatar Methods |
@@ -2483,6 +2614,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2483 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2614 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2484 | 2615 | ||
2485 | CheckHeartbeat(); | 2616 | CheckHeartbeat(); |
2617 | ScenePresence presence; | ||
2486 | 2618 | ||
2487 | ScenePresence sp = GetScenePresence(client.AgentId); | 2619 | ScenePresence sp = GetScenePresence(client.AgentId); |
2488 | 2620 | ||
@@ -2531,7 +2663,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2531 | 2663 | ||
2532 | EventManager.TriggerOnNewClient(client); | 2664 | EventManager.TriggerOnNewClient(client); |
2533 | if (vialogin) | 2665 | if (vialogin) |
2666 | { | ||
2534 | EventManager.TriggerOnClientLogin(client); | 2667 | EventManager.TriggerOnClientLogin(client); |
2668 | // Send initial parcel data | ||
2669 | Vector3 pos = sp.AbsolutePosition; | ||
2670 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2671 | land.SendLandUpdateToClient(client); | ||
2672 | } | ||
2535 | 2673 | ||
2536 | return sp; | 2674 | return sp; |
2537 | } | 2675 | } |
@@ -2621,19 +2759,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2621 | // and the scene presence and the client, if they exist | 2759 | // and the scene presence and the client, if they exist |
2622 | try | 2760 | try |
2623 | { | 2761 | { |
2624 | // We need to wait for the client to make UDP contact first. | 2762 | ScenePresence sp = GetScenePresence(agentID); |
2625 | // It's the UDP contact that creates the scene presence | 2763 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2626 | ScenePresence sp = WaitGetScenePresence(agentID); | 2764 | |
2627 | if (sp != null) | 2765 | if (sp != null) |
2628 | { | ||
2629 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2630 | |||
2631 | sp.ControllingClient.Close(); | 2766 | sp.ControllingClient.Close(); |
2632 | } | 2767 | |
2633 | else | ||
2634 | { | ||
2635 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2636 | } | ||
2637 | // BANG! SLASH! | 2768 | // BANG! SLASH! |
2638 | m_authenticateHandler.RemoveCircuit(agentID); | 2769 | m_authenticateHandler.RemoveCircuit(agentID); |
2639 | 2770 | ||
@@ -2678,6 +2809,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2678 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2809 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2679 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2810 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2680 | 2811 | ||
2812 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2813 | |||
2681 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2814 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2682 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2815 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2683 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2816 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2734,6 +2867,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2734 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2867 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2735 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2868 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2736 | client.OnCopyInventoryItem += CopyInventoryItem; | 2869 | client.OnCopyInventoryItem += CopyInventoryItem; |
2870 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2737 | client.OnMoveInventoryItem += MoveInventoryItem; | 2871 | client.OnMoveInventoryItem += MoveInventoryItem; |
2738 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2872 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2739 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2873 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2805,6 +2939,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2805 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 2939 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2806 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 2940 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2807 | 2941 | ||
2942 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
2943 | |||
2808 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 2944 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2809 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 2945 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2810 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 2946 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2907,15 +3043,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2907 | /// </summary> | 3043 | /// </summary> |
2908 | /// <param name="agentId">The avatar's Unique ID</param> | 3044 | /// <param name="agentId">The avatar's Unique ID</param> |
2909 | /// <param name="client">The IClientAPI for the client</param> | 3045 | /// <param name="client">The IClientAPI for the client</param> |
2910 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3046 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2911 | { | 3047 | { |
2912 | if (m_teleportModule != null) | 3048 | if (m_teleportModule != null) |
2913 | m_teleportModule.TeleportHome(agentId, client); | 3049 | return m_teleportModule.TeleportHome(agentId, client); |
2914 | else | 3050 | else |
2915 | { | 3051 | { |
2916 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3052 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2917 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3053 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2918 | } | 3054 | } |
3055 | return false; | ||
2919 | } | 3056 | } |
2920 | 3057 | ||
2921 | /// <summary> | 3058 | /// <summary> |
@@ -3025,6 +3162,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3025 | /// <param name="flags"></param> | 3162 | /// <param name="flags"></param> |
3026 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3163 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3027 | { | 3164 | { |
3165 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3166 | ScenePresence presence; | ||
3167 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3168 | { | ||
3169 | if (presence.Appearance != null) | ||
3170 | { | ||
3171 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3172 | } | ||
3173 | } | ||
3174 | |||
3028 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3175 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3029 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3176 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3030 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3177 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3093,8 +3240,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | regions.Remove(RegionInfo.RegionHandle); | 3240 | regions.Remove(RegionInfo.RegionHandle); |
3094 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3241 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3095 | } | 3242 | } |
3096 | 3243 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3097 | m_eventManager.TriggerClientClosed(agentID, this); | 3244 | m_eventManager.TriggerClientClosed(agentID, this); |
3245 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3098 | } | 3246 | } |
3099 | catch (NullReferenceException) | 3247 | catch (NullReferenceException) |
3100 | { | 3248 | { |
@@ -3156,9 +3304,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3156 | { | 3304 | { |
3157 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3305 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3158 | } | 3306 | } |
3159 | 3307 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3160 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3308 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3161 | // CleanDroppedAttachments(); | 3309 | // CleanDroppedAttachments(); |
3310 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3162 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3311 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3163 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3312 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3164 | } | 3313 | } |
@@ -3280,13 +3429,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3280 | sp = null; | 3429 | sp = null; |
3281 | } | 3430 | } |
3282 | 3431 | ||
3283 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3284 | 3432 | ||
3285 | //On login test land permisions | 3433 | //On login test land permisions |
3286 | if (vialogin) | 3434 | if (vialogin) |
3287 | { | 3435 | { |
3288 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3436 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3437 | if (cache != null) | ||
3438 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3439 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3289 | { | 3440 | { |
3441 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3290 | return false; | 3442 | return false; |
3291 | } | 3443 | } |
3292 | } | 3444 | } |
@@ -3310,8 +3462,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3310 | 3462 | ||
3311 | try | 3463 | try |
3312 | { | 3464 | { |
3313 | if (!AuthorizeUser(agent, out reason)) | 3465 | // Always check estate if this is a login. Always |
3314 | return false; | 3466 | // check if banned regions are to be blacked out. |
3467 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3468 | { | ||
3469 | if (!AuthorizeUser(agent, out reason)) | ||
3470 | return false; | ||
3471 | } | ||
3315 | } | 3472 | } |
3316 | catch (Exception e) | 3473 | catch (Exception e) |
3317 | { | 3474 | { |
@@ -3437,6 +3594,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3437 | } | 3594 | } |
3438 | 3595 | ||
3439 | // Honor parcel landing type and position. | 3596 | // Honor parcel landing type and position. |
3597 | /* | ||
3598 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3440 | if (land != null) | 3599 | if (land != null) |
3441 | { | 3600 | { |
3442 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3601 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3444,26 +3603,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3444 | agent.startpos = land.LandData.UserLocation; | 3603 | agent.startpos = land.LandData.UserLocation; |
3445 | } | 3604 | } |
3446 | } | 3605 | } |
3606 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3447 | } | 3607 | } |
3448 | 3608 | ||
3449 | return true; | 3609 | return true; |
3450 | } | 3610 | } |
3451 | 3611 | ||
3452 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3612 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3453 | { | 3613 | { |
3454 | 3614 | reason = String.Empty; | |
3455 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3615 | if (Permissions.IsGod(agentID)) |
3456 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3616 | return true; |
3617 | |||
3618 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3619 | if (land == null) | ||
3620 | return false; | ||
3621 | |||
3622 | bool banned = land.IsBannedFromLand(agentID); | ||
3623 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3457 | 3624 | ||
3458 | if (banned || restricted) | 3625 | if (banned || restricted) |
3459 | { | 3626 | { |
3460 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3627 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3461 | if (nearestParcel != null) | 3628 | if (nearestParcel != null) |
3462 | { | 3629 | { |
3463 | //Move agent to nearest allowed | 3630 | //Move agent to nearest allowed |
3464 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3631 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3465 | agent.startpos.X = newPosition.X; | 3632 | posX = newPosition.X; |
3466 | agent.startpos.Y = newPosition.Y; | 3633 | posY = newPosition.Y; |
3467 | } | 3634 | } |
3468 | else | 3635 | else |
3469 | { | 3636 | { |
@@ -3525,7 +3692,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3525 | 3692 | ||
3526 | if (!m_strictAccessControl) return true; | 3693 | if (!m_strictAccessControl) return true; |
3527 | if (Permissions.IsGod(agent.AgentID)) return true; | 3694 | if (Permissions.IsGod(agent.AgentID)) return true; |
3528 | 3695 | ||
3529 | if (AuthorizationService != null) | 3696 | if (AuthorizationService != null) |
3530 | { | 3697 | { |
3531 | if (!AuthorizationService.IsAuthorizedForRegion( | 3698 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3540,7 +3707,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3540 | 3707 | ||
3541 | if (m_regInfo.EstateSettings != null) | 3708 | if (m_regInfo.EstateSettings != null) |
3542 | { | 3709 | { |
3543 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3710 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3544 | { | 3711 | { |
3545 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3712 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3546 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3713 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3732,6 +3899,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3732 | 3899 | ||
3733 | // We have to wait until the viewer contacts this region after receiving EAC. | 3900 | // We have to wait until the viewer contacts this region after receiving EAC. |
3734 | // That calls AddNewClient, which finally creates the ScenePresence | 3901 | // That calls AddNewClient, which finally creates the ScenePresence |
3902 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3903 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3904 | { | ||
3905 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3906 | return false; | ||
3907 | } | ||
3908 | |||
3735 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3909 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3736 | if (nearestParcel == null) | 3910 | if (nearestParcel == null) |
3737 | { | 3911 | { |
@@ -3813,12 +3987,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3813 | return false; | 3987 | return false; |
3814 | } | 3988 | } |
3815 | 3989 | ||
3990 | public bool IncomingCloseAgent(UUID agentID) | ||
3991 | { | ||
3992 | return IncomingCloseAgent(agentID, false); | ||
3993 | } | ||
3994 | |||
3995 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3996 | { | ||
3997 | return IncomingCloseAgent(agentID, true); | ||
3998 | } | ||
3999 | |||
3816 | /// <summary> | 4000 | /// <summary> |
3817 | /// Tell a single agent to disconnect from the region. | 4001 | /// Tell a single agent to disconnect from the region. |
3818 | /// </summary> | 4002 | /// </summary> |
3819 | /// <param name="regionHandle"></param> | ||
3820 | /// <param name="agentID"></param> | 4003 | /// <param name="agentID"></param> |
3821 | public bool IncomingCloseAgent(UUID agentID) | 4004 | /// <param name="childOnly"></param> |
4005 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3822 | { | 4006 | { |
3823 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4007 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3824 | 4008 | ||
@@ -3830,7 +4014,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3830 | { | 4014 | { |
3831 | m_sceneGraph.removeUserCount(false); | 4015 | m_sceneGraph.removeUserCount(false); |
3832 | } | 4016 | } |
3833 | else | 4017 | else if (!childOnly) |
3834 | { | 4018 | { |
3835 | m_sceneGraph.removeUserCount(true); | 4019 | m_sceneGraph.removeUserCount(true); |
3836 | } | 4020 | } |
@@ -3846,9 +4030,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3846 | } | 4030 | } |
3847 | else | 4031 | else |
3848 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4032 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4033 | presence.ControllingClient.Close(false); | ||
4034 | } | ||
4035 | else if (!childOnly) | ||
4036 | { | ||
4037 | presence.ControllingClient.Close(true); | ||
3849 | } | 4038 | } |
3850 | |||
3851 | presence.ControllingClient.Close(); | ||
3852 | return true; | 4039 | return true; |
3853 | } | 4040 | } |
3854 | 4041 | ||
@@ -4430,34 +4617,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4430 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4617 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4431 | } | 4618 | } |
4432 | 4619 | ||
4433 | public int GetHealth() | 4620 | public int GetHealth(out int flags, out string message) |
4434 | { | 4621 | { |
4435 | // Returns: | 4622 | // Returns: |
4436 | // 1 = sim is up and accepting http requests. The heartbeat has | 4623 | // 1 = sim is up and accepting http requests. The heartbeat has |
4437 | // stopped and the sim is probably locked up, but a remote | 4624 | // stopped and the sim is probably locked up, but a remote |
4438 | // admin restart may succeed | 4625 | // admin restart may succeed |
4439 | // | 4626 | // |
4440 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4627 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4441 | // usable for people within and logins _may_ work | 4628 | // usable for people within |
4629 | // | ||
4630 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4631 | // unstable and will not accept new logins | ||
4442 | // | 4632 | // |
4443 | // 3 = We have seen a new user enter within the past 4 minutes | 4633 | // 4 = Sim is up and both packet threads are running. Sim is |
4634 | // likely usable | ||
4635 | // | ||
4636 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4444 | // which can be seen as positive confirmation of sim health | 4637 | // which can be seen as positive confirmation of sim health |
4445 | // | 4638 | // |
4639 | |||
4640 | flags = 0; | ||
4641 | message = String.Empty; | ||
4642 | |||
4643 | CheckHeartbeat(); | ||
4644 | |||
4645 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4646 | { | ||
4647 | // We're still starting | ||
4648 | // 0 means "in startup", it can't happen another way, since | ||
4649 | // to get here, we must be able to accept http connections | ||
4650 | return 0; | ||
4651 | } | ||
4652 | |||
4446 | int health=1; // Start at 1, means we're up | 4653 | int health=1; // Start at 1, means we're up |
4447 | 4654 | ||
4448 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4655 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4656 | { | ||
4657 | health+=1; | ||
4658 | flags |= 1; | ||
4659 | } | ||
4660 | |||
4661 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4662 | { | ||
4449 | health+=1; | 4663 | health+=1; |
4664 | flags |= 2; | ||
4665 | } | ||
4666 | |||
4667 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4668 | { | ||
4669 | health+=1; | ||
4670 | flags |= 4; | ||
4671 | } | ||
4450 | else | 4672 | else |
4673 | { | ||
4674 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4675 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4676 | proc.EnableRaisingEvents=false; | ||
4677 | proc.StartInfo.FileName = "/bin/kill"; | ||
4678 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4679 | proc.Start(); | ||
4680 | proc.WaitForExit(); | ||
4681 | Thread.Sleep(1000); | ||
4682 | Environment.Exit(1); | ||
4683 | } | ||
4684 | |||
4685 | if (flags != 7) | ||
4451 | return health; | 4686 | return health; |
4452 | 4687 | ||
4453 | // A login in the last 4 mins? We can't be doing too badly | 4688 | // A login in the last 4 mins? We can't be doing too badly |
4454 | // | 4689 | // |
4455 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4690 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4456 | health++; | 4691 | health++; |
4457 | else | ||
4458 | return health; | ||
4459 | |||
4460 | CheckHeartbeat(); | ||
4461 | 4692 | ||
4462 | return health; | 4693 | return health; |
4463 | } | 4694 | } |
@@ -4546,7 +4777,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4546 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4777 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4547 | if (wasUsingPhysics) | 4778 | if (wasUsingPhysics) |
4548 | { | 4779 | { |
4549 | 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 | 4780 | 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 |
4550 | } | 4781 | } |
4551 | } | 4782 | } |
4552 | 4783 | ||
@@ -4650,7 +4881,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4650 | if (m_firstHeartbeat) | 4881 | if (m_firstHeartbeat) |
4651 | return; | 4882 | return; |
4652 | 4883 | ||
4653 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4884 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4654 | StartTimer(); | 4885 | StartTimer(); |
4655 | } | 4886 | } |
4656 | 4887 | ||
@@ -4664,9 +4895,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4664 | get { return m_allowScriptCrossings; } | 4895 | get { return m_allowScriptCrossings; } |
4665 | } | 4896 | } |
4666 | 4897 | ||
4667 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 4898 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4899 | { | ||
4900 | return GetNearestAllowedPosition(avatar, null); | ||
4901 | } | ||
4902 | |||
4903 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4668 | { | 4904 | { |
4669 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 4905 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4670 | 4906 | ||
4671 | if (nearestParcel != null) | 4907 | if (nearestParcel != null) |
4672 | { | 4908 | { |
@@ -4675,10 +4911,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4675 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4911 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4676 | if (nearestPoint != null) | 4912 | if (nearestPoint != null) |
4677 | { | 4913 | { |
4678 | // m_log.DebugFormat( | 4914 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4679 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4680 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4681 | |||
4682 | return nearestPoint.Value; | 4915 | return nearestPoint.Value; |
4683 | } | 4916 | } |
4684 | 4917 | ||
@@ -4688,17 +4921,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4688 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4921 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4689 | if (nearestPoint != null) | 4922 | if (nearestPoint != null) |
4690 | { | 4923 | { |
4691 | // m_log.DebugFormat( | 4924 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4692 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4693 | |||
4694 | return nearestPoint.Value; | 4925 | return nearestPoint.Value; |
4695 | } | 4926 | } |
4696 | 4927 | ||
4697 | //Ultimate backup if we have no idea where they are | 4928 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4698 | // m_log.DebugFormat( | 4929 | if (dest != excludeParcel) |
4699 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 4930 | { |
4931 | // Ultimate backup if we have no idea where they are and | ||
4932 | // the last allowed position was in another parcel | ||
4933 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
4934 | return avatar.lastKnownAllowedPosition; | ||
4935 | } | ||
4700 | 4936 | ||
4701 | return avatar.lastKnownAllowedPosition; | 4937 | // else fall through to region edge |
4702 | } | 4938 | } |
4703 | 4939 | ||
4704 | //Go to the edge, this happens in teleporting to a region with no available parcels | 4940 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4732,13 +4968,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4732 | 4968 | ||
4733 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 4969 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4734 | { | 4970 | { |
4971 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
4972 | } | ||
4973 | |||
4974 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
4975 | { | ||
4735 | List<ILandObject> all = AllParcels(); | 4976 | List<ILandObject> all = AllParcels(); |
4736 | float minParcelDistance = float.MaxValue; | 4977 | float minParcelDistance = float.MaxValue; |
4737 | ILandObject nearestParcel = null; | 4978 | ILandObject nearestParcel = null; |
4738 | 4979 | ||
4739 | foreach (var parcel in all) | 4980 | foreach (var parcel in all) |
4740 | { | 4981 | { |
4741 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 4982 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4742 | { | 4983 | { |
4743 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 4984 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4744 | if (parcelDistance < minParcelDistance) | 4985 | if (parcelDistance < minParcelDistance) |
@@ -4980,7 +5221,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
4980 | mapModule.GenerateMaptile(); | 5221 | mapModule.GenerateMaptile(); |
4981 | } | 5222 | } |
4982 | 5223 | ||
4983 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5224 | // public void CleanDroppedAttachments() |
5225 | // { | ||
5226 | // List<SceneObjectGroup> objectsToDelete = | ||
5227 | // new List<SceneObjectGroup>(); | ||
5228 | // | ||
5229 | // lock (m_cleaningAttachments) | ||
5230 | // { | ||
5231 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5232 | // { | ||
5233 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5234 | // { | ||
5235 | // UUID agentID = grp.OwnerID; | ||
5236 | // if (agentID == UUID.Zero) | ||
5237 | // { | ||
5238 | // objectsToDelete.Add(grp); | ||
5239 | // return; | ||
5240 | // } | ||
5241 | // | ||
5242 | // ScenePresence sp = GetScenePresence(agentID); | ||
5243 | // if (sp == null) | ||
5244 | // { | ||
5245 | // objectsToDelete.Add(grp); | ||
5246 | // return; | ||
5247 | // } | ||
5248 | // } | ||
5249 | // }); | ||
5250 | // } | ||
5251 | // | ||
5252 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5253 | // { | ||
5254 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5255 | // DeleteSceneObject(grp, true); | ||
5256 | // } | ||
5257 | // } | ||
5258 | |||
5259 | public void ThreadAlive(int threadCode) | ||
5260 | { | ||
5261 | switch(threadCode) | ||
5262 | { | ||
5263 | case 1: // Incoming | ||
5264 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5265 | break; | ||
5266 | case 2: // Incoming | ||
5267 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5268 | break; | ||
5269 | } | ||
5270 | } | ||
5271 | |||
5272 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
4984 | { | 5273 | { |
4985 | RegenerateMaptile(); | 5274 | RegenerateMaptile(); |
4986 | 5275 | ||
@@ -4999,6 +5288,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4999 | // child agent creation, thereby emulating the SL behavior. | 5288 | // child agent creation, thereby emulating the SL behavior. |
5000 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5289 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5001 | { | 5290 | { |
5291 | reason = "You are banned from the region"; | ||
5292 | |||
5293 | if (Permissions.IsGod(agentID)) | ||
5294 | { | ||
5295 | reason = String.Empty; | ||
5296 | return true; | ||
5297 | } | ||
5298 | |||
5002 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5299 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5003 | 5300 | ||
5004 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5301 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5010,6 +5307,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5010 | } | 5307 | } |
5011 | } | 5308 | } |
5012 | 5309 | ||
5310 | ScenePresence presence = GetScenePresence(agentID); | ||
5311 | IClientAPI client = null; | ||
5312 | AgentCircuitData aCircuit = null; | ||
5313 | |||
5314 | if (presence != null) | ||
5315 | { | ||
5316 | client = presence.ControllingClient; | ||
5317 | if (client != null) | ||
5318 | aCircuit = client.RequestClientInfo(); | ||
5319 | } | ||
5320 | |||
5321 | // We may be called before there is a presence or a client. | ||
5322 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5323 | if (client == null) | ||
5324 | { | ||
5325 | aCircuit = new AgentCircuitData(); | ||
5326 | aCircuit.AgentID = agentID; | ||
5327 | aCircuit.firstname = String.Empty; | ||
5328 | aCircuit.lastname = String.Empty; | ||
5329 | } | ||
5330 | |||
5331 | try | ||
5332 | { | ||
5333 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5334 | { | ||
5335 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5336 | return false; | ||
5337 | } | ||
5338 | } | ||
5339 | catch (Exception e) | ||
5340 | { | ||
5341 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5342 | return false; | ||
5343 | } | ||
5344 | |||
5013 | if (position == Vector3.Zero) // Teleport | 5345 | if (position == Vector3.Zero) // Teleport |
5014 | { | 5346 | { |
5015 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5347 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5038,13 +5370,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5038 | } | 5370 | } |
5039 | } | 5371 | } |
5040 | } | 5372 | } |
5373 | |||
5374 | float posX = 128.0f; | ||
5375 | float posY = 128.0f; | ||
5376 | |||
5377 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5378 | { | ||
5379 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5380 | return false; | ||
5381 | } | ||
5382 | } | ||
5383 | else // Walking | ||
5384 | { | ||
5385 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5386 | if (land == null) | ||
5387 | return false; | ||
5388 | |||
5389 | bool banned = land.IsBannedFromLand(agentID); | ||
5390 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5391 | |||
5392 | if (banned || restricted) | ||
5393 | return false; | ||
5041 | } | 5394 | } |
5042 | 5395 | ||
5043 | reason = String.Empty; | 5396 | reason = String.Empty; |
5044 | return true; | 5397 | return true; |
5045 | } | 5398 | } |
5046 | 5399 | ||
5047 | /// <summary> | 5400 | public void StartTimerWatchdog() |
5401 | { | ||
5402 | m_timerWatchdog.Interval = 1000; | ||
5403 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5404 | m_timerWatchdog.AutoReset = true; | ||
5405 | m_timerWatchdog.Start(); | ||
5406 | } | ||
5407 | |||
5408 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5409 | { | ||
5410 | CheckHeartbeat(); | ||
5411 | } | ||
5412 | |||
5048 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5413 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5049 | /// autopilot that moves an avatar to a sit target!. | 5414 | /// autopilot that moves an avatar to a sit target!. |
5050 | /// </summary> | 5415 | /// </summary> |