diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 723 |
1 files changed, 570 insertions, 153 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e8f00a4..fd20c60 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -51,6 +51,7 @@ using OpenSim.Region.Physics.Manager; | |||
51 | using Timer=System.Timers.Timer; | 51 | using Timer=System.Timers.Timer; |
52 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; | 52 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; |
53 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 53 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
54 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
54 | 55 | ||
55 | namespace OpenSim.Region.Framework.Scenes | 56 | namespace OpenSim.Region.Framework.Scenes |
56 | { | 57 | { |
@@ -226,8 +227,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | // TODO: need to figure out how allow client agents but deny | 227 | // TODO: need to figure out how allow client agents but deny |
227 | // root agents when ACL denies access to root agent | 228 | // root agents when ACL denies access to root agent |
228 | public bool m_strictAccessControl = true; | 229 | public bool m_strictAccessControl = true; |
229 | 230 | public bool m_seeIntoBannedRegion = false; | |
230 | public int MaxUndoCount { get; set; } | 231 | public int MaxUndoCount = 5; |
231 | 232 | ||
232 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 233 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
233 | public bool LoginLock = false; | 234 | public bool LoginLock = false; |
@@ -243,11 +244,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
243 | 244 | ||
244 | protected int m_splitRegionID; | 245 | protected int m_splitRegionID; |
245 | protected Timer m_restartWaitTimer = new Timer(); | 246 | protected Timer m_restartWaitTimer = new Timer(); |
247 | protected Timer m_timerWatchdog = new Timer(); | ||
246 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 248 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
247 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 249 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
248 | protected string m_simulatorVersion = "OpenSimulator Server"; | 250 | protected string m_simulatorVersion = "OpenSimulator Server"; |
249 | protected AgentCircuitManager m_authenticateHandler; | 251 | protected AgentCircuitManager m_authenticateHandler; |
250 | protected SceneCommunicationService m_sceneGridService; | 252 | protected SceneCommunicationService m_sceneGridService; |
253 | protected ISnmpModule m_snmpService = null; | ||
251 | 254 | ||
252 | protected ISimulationDataService m_SimulationDataService; | 255 | protected ISimulationDataService m_SimulationDataService; |
253 | protected IEstateDataService m_EstateDataService; | 256 | protected IEstateDataService m_EstateDataService; |
@@ -310,8 +313,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
310 | private int m_update_presences = 1; // Update scene presence movements | 313 | private int m_update_presences = 1; // Update scene presence movements |
311 | private int m_update_events = 1; | 314 | private int m_update_events = 1; |
312 | private int m_update_backup = 200; | 315 | private int m_update_backup = 200; |
313 | private int m_update_terrain = 50; | 316 | private int m_update_terrain = 1000; |
314 | // private int m_update_land = 1; | 317 | private int m_update_land = 10; |
315 | private int m_update_coarse_locations = 50; | 318 | private int m_update_coarse_locations = 50; |
316 | 319 | ||
317 | private int agentMS; | 320 | private int agentMS; |
@@ -324,13 +327,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
324 | private int backupMS; | 327 | private int backupMS; |
325 | private int terrainMS; | 328 | private int terrainMS; |
326 | private int landMS; | 329 | private int landMS; |
327 | private int spareMS; | ||
328 | 330 | ||
329 | /// <summary> | 331 | /// <summary> |
330 | /// Tick at which the last frame was processed. | 332 | /// Tick at which the last frame was processed. |
331 | /// </summary> | 333 | /// </summary> |
332 | private int m_lastFrameTick; | 334 | private int m_lastFrameTick; |
333 | 335 | ||
336 | public bool CombineRegions = false; | ||
334 | /// <summary> | 337 | /// <summary> |
335 | /// Tick at which the last maintenance run occurred. | 338 | /// Tick at which the last maintenance run occurred. |
336 | /// </summary> | 339 | /// </summary> |
@@ -350,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 353 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
351 | private volatile bool m_backingup; | 354 | private volatile bool m_backingup; |
352 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 355 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
353 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 356 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
354 | 357 | ||
355 | private string m_defaultScriptEngine; | 358 | private string m_defaultScriptEngine; |
356 | 359 | ||
@@ -359,6 +362,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | /// </summary> | 362 | /// </summary> |
360 | private int m_LastLogin; | 363 | private int m_LastLogin; |
361 | 364 | ||
365 | private int m_lastIncoming; | ||
366 | private int m_lastOutgoing; | ||
367 | private int m_hbRestarts = 0; | ||
368 | |||
369 | |||
362 | /// <summary> | 370 | /// <summary> |
363 | /// Thread that runs the scene loop. | 371 | /// Thread that runs the scene loop. |
364 | /// </summary> | 372 | /// </summary> |
@@ -399,7 +407,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
399 | private volatile bool m_active; | 407 | private volatile bool m_active; |
400 | 408 | ||
401 | // private int m_lastUpdate; | 409 | // private int m_lastUpdate; |
402 | // private bool m_firstHeartbeat = true; | 410 | private bool m_firstHeartbeat = true; |
403 | 411 | ||
404 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 412 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
405 | private bool m_reprioritizationEnabled = true; | 413 | private bool m_reprioritizationEnabled = true; |
@@ -443,6 +451,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
443 | get { return m_sceneGridService; } | 451 | get { return m_sceneGridService; } |
444 | } | 452 | } |
445 | 453 | ||
454 | public ISnmpModule SnmpService | ||
455 | { | ||
456 | get | ||
457 | { | ||
458 | if (m_snmpService == null) | ||
459 | { | ||
460 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
461 | } | ||
462 | |||
463 | return m_snmpService; | ||
464 | } | ||
465 | } | ||
466 | |||
446 | public ISimulationDataService SimulationDataService | 467 | public ISimulationDataService SimulationDataService |
447 | { | 468 | { |
448 | get | 469 | get |
@@ -735,6 +756,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
735 | m_SimulationDataService = simDataService; | 756 | m_SimulationDataService = simDataService; |
736 | m_EstateDataService = estateDataService; | 757 | m_EstateDataService = estateDataService; |
737 | m_regionHandle = RegionInfo.RegionHandle; | 758 | m_regionHandle = RegionInfo.RegionHandle; |
759 | m_lastIncoming = 0; | ||
760 | m_lastOutgoing = 0; | ||
738 | 761 | ||
739 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 762 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
740 | m_asyncSceneObjectDeleter.Enabled = true; | 763 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -828,7 +851,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
828 | 851 | ||
829 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 852 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
830 | 853 | ||
831 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 854 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
832 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 855 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
833 | if (!UseBackup) | 856 | if (!UseBackup) |
834 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 857 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -836,10 +859,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
836 | //Animation states | 859 | //Animation states |
837 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 860 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
838 | 861 | ||
839 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 862 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
840 | 863 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | |
841 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
842 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
843 | 864 | ||
844 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 865 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
845 | if (RegionInfo.NonphysPrimMin > 0) | 866 | if (RegionInfo.NonphysPrimMin > 0) |
@@ -860,11 +881,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
860 | } | 881 | } |
861 | 882 | ||
862 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 883 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
884 | |||
863 | if (RegionInfo.PhysPrimMax > 0) | 885 | if (RegionInfo.PhysPrimMax > 0) |
864 | { | 886 | { |
865 | m_maxPhys = RegionInfo.PhysPrimMax; | 887 | m_maxPhys = RegionInfo.PhysPrimMax; |
866 | } | 888 | } |
867 | 889 | ||
890 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
891 | if (RegionInfo.LinksetCapacity > 0) | ||
892 | { | ||
893 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
894 | } | ||
895 | |||
896 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
897 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
898 | |||
868 | // Here, if clamping is requested in either global or | 899 | // Here, if clamping is requested in either global or |
869 | // local config, it will be used | 900 | // local config, it will be used |
870 | // | 901 | // |
@@ -874,13 +905,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
874 | m_clampPrimSize = true; | 905 | m_clampPrimSize = true; |
875 | } | 906 | } |
876 | 907 | ||
877 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 908 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
878 | if (RegionInfo.LinksetCapacity > 0) | ||
879 | { | ||
880 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
881 | } | ||
882 | |||
883 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
884 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 909 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
885 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 910 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
886 | m_dontPersistBefore = | 911 | m_dontPersistBefore = |
@@ -891,11 +916,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
891 | m_persistAfter *= 10000000; | 916 | m_persistAfter *= 10000000; |
892 | 917 | ||
893 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 918 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
894 | 919 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
895 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
896 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
897 | 920 | ||
898 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 921 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
922 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
923 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
899 | 924 | ||
900 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; | 925 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; |
901 | 926 | ||
@@ -940,7 +965,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
940 | 965 | ||
941 | if (grant.Length > 0) | 966 | if (grant.Length > 0) |
942 | { | 967 | { |
943 | foreach (string viewer in grant.Split('|')) | 968 | foreach (string viewer in grant.Split(',')) |
944 | { | 969 | { |
945 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 970 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
946 | } | 971 | } |
@@ -952,7 +977,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
952 | 977 | ||
953 | if (grant.Length > 0) | 978 | if (grant.Length > 0) |
954 | { | 979 | { |
955 | foreach (string viewer in grant.Split('|')) | 980 | foreach (string viewer in grant.Split(',')) |
956 | { | 981 | { |
957 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 982 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
958 | } | 983 | } |
@@ -1012,6 +1037,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1012 | StatsReporter = new SimStatsReporter(this); | 1037 | StatsReporter = new SimStatsReporter(this); |
1013 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1038 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1014 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1039 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1040 | |||
1041 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1015 | } | 1042 | } |
1016 | 1043 | ||
1017 | public Scene(RegionInfo regInfo) : base(regInfo) | 1044 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1307,8 +1334,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1307 | // Stop all client threads. | 1334 | // Stop all client threads. |
1308 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1335 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1309 | 1336 | ||
1310 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1337 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1311 | EventManager.TriggerSceneShuttingDown(this); | 1338 | EventManager.TriggerSceneShuttingDown(this); |
1339 | |||
1340 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1341 | |||
1312 | Backup(false); | 1342 | Backup(false); |
1313 | m_sceneGraph.Close(); | 1343 | m_sceneGraph.Close(); |
1314 | 1344 | ||
@@ -1322,6 +1352,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1322 | // attempt to reference a null or disposed physics scene. | 1352 | // attempt to reference a null or disposed physics scene. |
1323 | if (PhysicsScene != null) | 1353 | if (PhysicsScene != null) |
1324 | { | 1354 | { |
1355 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1325 | PhysicsScene phys = PhysicsScene; | 1356 | PhysicsScene phys = PhysicsScene; |
1326 | // remove the physics engine from both Scene and SceneGraph | 1357 | // remove the physics engine from both Scene and SceneGraph |
1327 | PhysicsScene = null; | 1358 | PhysicsScene = null; |
@@ -1344,11 +1375,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1344 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1375 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1345 | if (m_heartbeatThread != null) | 1376 | if (m_heartbeatThread != null) |
1346 | { | 1377 | { |
1378 | m_hbRestarts++; | ||
1379 | if(m_hbRestarts > 10) | ||
1380 | Environment.Exit(1); | ||
1381 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1382 | |||
1383 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1384 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1385 | //proc.EnableRaisingEvents=false; | ||
1386 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1387 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1388 | //proc.Start(); | ||
1389 | //proc.WaitForExit(); | ||
1390 | //Thread.Sleep(1000); | ||
1391 | //Environment.Exit(1); | ||
1347 | m_heartbeatThread.Abort(); | 1392 | m_heartbeatThread.Abort(); |
1393 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1348 | m_heartbeatThread = null; | 1394 | m_heartbeatThread = null; |
1349 | } | 1395 | } |
1350 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1396 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1351 | 1397 | ||
1398 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1399 | |||
1400 | |||
1352 | m_heartbeatThread | 1401 | m_heartbeatThread |
1353 | = Watchdog.StartThread( | 1402 | = Watchdog.StartThread( |
1354 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1403 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1491,16 +1540,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1491 | endFrame = Frame + frames; | 1540 | endFrame = Frame + frames; |
1492 | 1541 | ||
1493 | float physicsFPS = 0f; | 1542 | float physicsFPS = 0f; |
1494 | int previousFrameTick, tmpMS; | 1543 | int tmpMS; |
1495 | int maintc = Util.EnvironmentTickCount(); | 1544 | int previousFrameTick; |
1545 | int maintc; | ||
1546 | int sleepMS; | ||
1547 | int framestart; | ||
1496 | 1548 | ||
1497 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1549 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1498 | { | 1550 | { |
1551 | framestart = Util.EnvironmentTickCount(); | ||
1499 | ++Frame; | 1552 | ++Frame; |
1500 | 1553 | ||
1501 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1554 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1502 | 1555 | ||
1503 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1556 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1504 | 1557 | ||
1505 | try | 1558 | try |
1506 | { | 1559 | { |
@@ -1552,6 +1605,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1552 | m_sceneGraph.UpdatePresences(); | 1605 | m_sceneGraph.UpdatePresences(); |
1553 | 1606 | ||
1554 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1607 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1608 | |||
1555 | 1609 | ||
1556 | // Delete temp-on-rez stuff | 1610 | // Delete temp-on-rez stuff |
1557 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1611 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1633,34 +1687,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1633 | 1687 | ||
1634 | Watchdog.UpdateThread(); | 1688 | Watchdog.UpdateThread(); |
1635 | 1689 | ||
1690 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1691 | |||
1692 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1693 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1694 | StatsReporter.AddFPS(1); | ||
1695 | |||
1696 | StatsReporter.addAgentMS(agentMS); | ||
1697 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1698 | StatsReporter.addOtherMS(otherMS); | ||
1699 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1700 | |||
1636 | previousFrameTick = m_lastFrameTick; | 1701 | previousFrameTick = m_lastFrameTick; |
1637 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1702 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1638 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1703 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1639 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1704 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1640 | 1705 | ||
1706 | m_firstHeartbeat = false; | ||
1707 | |||
1708 | sleepMS = Util.EnvironmentTickCount(); | ||
1709 | |||
1641 | if (tmpMS > 0) | 1710 | if (tmpMS > 0) |
1642 | { | ||
1643 | Thread.Sleep(tmpMS); | 1711 | Thread.Sleep(tmpMS); |
1644 | spareMS += tmpMS; | ||
1645 | } | ||
1646 | |||
1647 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | ||
1648 | maintc = Util.EnvironmentTickCount(); | ||
1649 | 1712 | ||
1650 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1713 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1714 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1715 | StatsReporter.addSleepMS(sleepMS); | ||
1716 | StatsReporter.addFrameMS(frameMS); | ||
1651 | 1717 | ||
1652 | // if (Frame%m_update_avatars == 0) | 1718 | // if (Frame%m_update_avatars == 0) |
1653 | // UpdateInWorldTime(); | 1719 | // UpdateInWorldTime(); |
1654 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1655 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1656 | StatsReporter.AddFPS(1); | ||
1657 | 1720 | ||
1658 | StatsReporter.addFrameMS(frameMS); | ||
1659 | StatsReporter.addAgentMS(agentMS); | ||
1660 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1661 | StatsReporter.addOtherMS(otherMS); | ||
1662 | StatsReporter.AddSpareMS(spareMS); | ||
1663 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1664 | 1721 | ||
1665 | // Optionally warn if a frame takes double the amount of time that it should. | 1722 | // Optionally warn if a frame takes double the amount of time that it should. |
1666 | if (DebugUpdates | 1723 | if (DebugUpdates |
@@ -1677,7 +1734,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1677 | public void AddGroupTarget(SceneObjectGroup grp) | 1734 | public void AddGroupTarget(SceneObjectGroup grp) |
1678 | { | 1735 | { |
1679 | lock (m_groupsWithTargets) | 1736 | lock (m_groupsWithTargets) |
1680 | m_groupsWithTargets[grp.UUID] = grp; | 1737 | m_groupsWithTargets[grp.UUID] = 0; |
1681 | } | 1738 | } |
1682 | 1739 | ||
1683 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1740 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1688,18 +1745,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1688 | 1745 | ||
1689 | private void CheckAtTargets() | 1746 | private void CheckAtTargets() |
1690 | { | 1747 | { |
1691 | List<SceneObjectGroup> objs = null; | 1748 | List<UUID> objs = null; |
1692 | 1749 | ||
1693 | lock (m_groupsWithTargets) | 1750 | lock (m_groupsWithTargets) |
1694 | { | 1751 | { |
1695 | if (m_groupsWithTargets.Count != 0) | 1752 | if (m_groupsWithTargets.Count != 0) |
1696 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1753 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1697 | } | 1754 | } |
1698 | 1755 | ||
1699 | if (objs != null) | 1756 | if (objs != null) |
1700 | { | 1757 | { |
1701 | foreach (SceneObjectGroup entry in objs) | 1758 | foreach (UUID entry in objs) |
1702 | entry.checkAtTargets(); | 1759 | { |
1760 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1761 | if (grp == null) | ||
1762 | m_groupsWithTargets.Remove(entry); | ||
1763 | else | ||
1764 | grp.checkAtTargets(); | ||
1765 | } | ||
1703 | } | 1766 | } |
1704 | } | 1767 | } |
1705 | 1768 | ||
@@ -1778,7 +1841,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1778 | msg.fromAgentName = "Server"; | 1841 | msg.fromAgentName = "Server"; |
1779 | msg.dialog = (byte)19; // Object msg | 1842 | msg.dialog = (byte)19; // Object msg |
1780 | msg.fromGroup = false; | 1843 | msg.fromGroup = false; |
1781 | msg.offline = (byte)0; | 1844 | msg.offline = (byte)1; |
1782 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1845 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1783 | msg.Position = Vector3.Zero; | 1846 | msg.Position = Vector3.Zero; |
1784 | msg.RegionID = RegionInfo.RegionID.Guid; | 1847 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2007,7 +2070,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2007 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2070 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
2008 | } | 2071 | } |
2009 | 2072 | ||
2010 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2073 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
2011 | { | 2074 | { |
2012 | if (PhysicsScene == null) | 2075 | if (PhysicsScene == null) |
2013 | return null; | 2076 | return null; |
@@ -2029,14 +2092,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2029 | /// <returns></returns> | 2092 | /// <returns></returns> |
2030 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2093 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2031 | { | 2094 | { |
2095 | |||
2096 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2097 | Vector3 wpos = Vector3.Zero; | ||
2098 | // Check for water surface intersection from above | ||
2099 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2100 | { | ||
2101 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2102 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2103 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2104 | wpos.Z = wheight; | ||
2105 | } | ||
2106 | |||
2032 | Vector3 pos = Vector3.Zero; | 2107 | Vector3 pos = Vector3.Zero; |
2033 | if (RayEndIsIntersection == (byte)1) | 2108 | if (RayEndIsIntersection == (byte)1) |
2034 | { | 2109 | { |
2035 | pos = RayEnd; | 2110 | pos = RayEnd; |
2036 | return pos; | ||
2037 | } | 2111 | } |
2038 | 2112 | else if (RayTargetID != UUID.Zero) | |
2039 | if (RayTargetID != UUID.Zero) | ||
2040 | { | 2113 | { |
2041 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2114 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2042 | 2115 | ||
@@ -2058,7 +2131,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2058 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2131 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2059 | 2132 | ||
2060 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2133 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2061 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2134 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2062 | float ScaleOffset = 0.5f; | 2135 | float ScaleOffset = 0.5f; |
2063 | 2136 | ||
2064 | // If we hit something | 2137 | // If we hit something |
@@ -2081,13 +2154,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2081 | //pos.Z -= 0.25F; | 2154 | //pos.Z -= 0.25F; |
2082 | 2155 | ||
2083 | } | 2156 | } |
2084 | |||
2085 | return pos; | ||
2086 | } | 2157 | } |
2087 | else | 2158 | else |
2088 | { | 2159 | { |
2089 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2160 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2090 | |||
2091 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2161 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2092 | 2162 | ||
2093 | // Un-comment the following line to print the raytrace results to the console. | 2163 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2096,13 +2166,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2096 | if (ei.HitTF) | 2166 | if (ei.HitTF) |
2097 | { | 2167 | { |
2098 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2168 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2099 | } else | 2169 | } |
2170 | else | ||
2100 | { | 2171 | { |
2101 | // fall back to our stupid functionality | 2172 | // fall back to our stupid functionality |
2102 | pos = RayEnd; | 2173 | pos = RayEnd; |
2103 | } | 2174 | } |
2104 | |||
2105 | return pos; | ||
2106 | } | 2175 | } |
2107 | } | 2176 | } |
2108 | else | 2177 | else |
@@ -2113,8 +2182,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2113 | //increase height so its above the ground. | 2182 | //increase height so its above the ground. |
2114 | //should be getting the normal of the ground at the rez point and using that? | 2183 | //should be getting the normal of the ground at the rez point and using that? |
2115 | pos.Z += scale.Z / 2f; | 2184 | pos.Z += scale.Z / 2f; |
2116 | return pos; | 2185 | // return pos; |
2117 | } | 2186 | } |
2187 | |||
2188 | // check against posible water intercept | ||
2189 | if (wpos.Z > pos.Z) pos = wpos; | ||
2190 | return pos; | ||
2118 | } | 2191 | } |
2119 | 2192 | ||
2120 | 2193 | ||
@@ -2205,12 +2278,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2205 | { | 2278 | { |
2206 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2279 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2207 | { | 2280 | { |
2281 | sceneObject.IsDeleted = false; | ||
2208 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2282 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2209 | return true; | 2283 | return true; |
2210 | } | 2284 | } |
2211 | 2285 | ||
2212 | return false; | 2286 | return false; |
2213 | |||
2214 | } | 2287 | } |
2215 | 2288 | ||
2216 | /// <summary> | 2289 | /// <summary> |
@@ -2302,6 +2375,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2302 | /// </summary> | 2375 | /// </summary> |
2303 | public void DeleteAllSceneObjects() | 2376 | public void DeleteAllSceneObjects() |
2304 | { | 2377 | { |
2378 | DeleteAllSceneObjects(false); | ||
2379 | } | ||
2380 | |||
2381 | /// <summary> | ||
2382 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2383 | /// </summary> | ||
2384 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2385 | { | ||
2386 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2305 | lock (Entities) | 2387 | lock (Entities) |
2306 | { | 2388 | { |
2307 | EntityBase[] entities = Entities.GetEntities(); | 2389 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2310,11 +2392,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2310 | if (e is SceneObjectGroup) | 2392 | if (e is SceneObjectGroup) |
2311 | { | 2393 | { |
2312 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2394 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2313 | if (!sog.IsAttachment) | 2395 | if (sog != null && !sog.IsAttachment) |
2314 | DeleteSceneObject((SceneObjectGroup)e, false); | 2396 | { |
2397 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2398 | { | ||
2399 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2400 | } | ||
2401 | else | ||
2402 | { | ||
2403 | toReturn.Add((SceneObjectGroup)e); | ||
2404 | } | ||
2405 | } | ||
2315 | } | 2406 | } |
2316 | } | 2407 | } |
2317 | } | 2408 | } |
2409 | if (toReturn.Count > 0) | ||
2410 | { | ||
2411 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2412 | } | ||
2318 | } | 2413 | } |
2319 | 2414 | ||
2320 | /// <summary> | 2415 | /// <summary> |
@@ -2349,6 +2444,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2349 | 2444 | ||
2350 | foreach (SceneObjectPart part in partList) | 2445 | foreach (SceneObjectPart part in partList) |
2351 | { | 2446 | { |
2447 | if (part.KeyframeMotion != null) | ||
2448 | { | ||
2449 | part.KeyframeMotion.Delete(); | ||
2450 | part.KeyframeMotion = null; | ||
2451 | } | ||
2452 | |||
2352 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) | 2453 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) |
2353 | { | 2454 | { |
2354 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? | 2455 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? |
@@ -2366,6 +2467,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2366 | } | 2467 | } |
2367 | 2468 | ||
2368 | group.DeleteGroupFromScene(silent); | 2469 | group.DeleteGroupFromScene(silent); |
2470 | if (!silent) | ||
2471 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2369 | 2472 | ||
2370 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2473 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2371 | } | 2474 | } |
@@ -2655,7 +2758,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2655 | // If the user is banned, we won't let any of their objects | 2758 | // If the user is banned, we won't let any of their objects |
2656 | // enter. Period. | 2759 | // enter. Period. |
2657 | // | 2760 | // |
2658 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2761 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2659 | { | 2762 | { |
2660 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2763 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2661 | return false; | 2764 | return false; |
@@ -2690,6 +2793,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2690 | // before we restart the scripts, or else some functions won't work. | 2793 | // before we restart the scripts, or else some functions won't work. |
2691 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); | 2794 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); |
2692 | newObject.ResumeScripts(); | 2795 | newObject.ResumeScripts(); |
2796 | |||
2797 | if (newObject.RootPart.KeyframeMotion != null) | ||
2798 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2693 | } | 2799 | } |
2694 | 2800 | ||
2695 | // Do this as late as possible so that listeners have full access to the incoming object | 2801 | // Do this as late as possible so that listeners have full access to the incoming object |
@@ -2707,6 +2813,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2707 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2813 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2708 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2814 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2709 | { | 2815 | { |
2816 | if (sceneObject.OwnerID == UUID.Zero) | ||
2817 | { | ||
2818 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2819 | return false; | ||
2820 | } | ||
2821 | |||
2822 | // If the user is banned, we won't let any of their objects | ||
2823 | // enter. Period. | ||
2824 | // | ||
2825 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2826 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2827 | { | ||
2828 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2829 | |||
2830 | return false; | ||
2831 | } | ||
2832 | |||
2710 | // Force allocation of new LocalId | 2833 | // Force allocation of new LocalId |
2711 | // | 2834 | // |
2712 | SceneObjectPart[] parts = sceneObject.Parts; | 2835 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2740,16 +2863,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2740 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2863 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2741 | 2864 | ||
2742 | if (AttachmentsModule != null) | 2865 | if (AttachmentsModule != null) |
2743 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); | 2866 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); |
2744 | } | 2867 | } |
2745 | else | 2868 | else |
2746 | { | 2869 | { |
2870 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2747 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2871 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2748 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2872 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2749 | } | 2873 | } |
2874 | if (sceneObject.OwnerID == UUID.Zero) | ||
2875 | { | ||
2876 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2877 | return false; | ||
2878 | } | ||
2750 | } | 2879 | } |
2751 | else | 2880 | else |
2752 | { | 2881 | { |
2882 | if (sceneObject.OwnerID == UUID.Zero) | ||
2883 | { | ||
2884 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2885 | return false; | ||
2886 | } | ||
2753 | AddRestoredSceneObject(sceneObject, true, false); | 2887 | AddRestoredSceneObject(sceneObject, true, false); |
2754 | } | 2888 | } |
2755 | 2889 | ||
@@ -2766,6 +2900,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2766 | return 2; // StateSource.PrimCrossing | 2900 | return 2; // StateSource.PrimCrossing |
2767 | } | 2901 | } |
2768 | 2902 | ||
2903 | public int GetUserFlags(UUID user) | ||
2904 | { | ||
2905 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2906 | /* | ||
2907 | ScenePresence sp; | ||
2908 | if (TryGetScenePresence(user, out sp)) | ||
2909 | { | ||
2910 | return sp.UserFlags; | ||
2911 | } | ||
2912 | else | ||
2913 | { | ||
2914 | */ | ||
2915 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2916 | if (uac == null) | ||
2917 | return 0; | ||
2918 | return uac.UserFlags; | ||
2919 | //} | ||
2920 | } | ||
2769 | #endregion | 2921 | #endregion |
2770 | 2922 | ||
2771 | #region Add/Remove Avatar Methods | 2923 | #region Add/Remove Avatar Methods |
@@ -2798,7 +2950,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2798 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2950 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2799 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2951 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2800 | 2952 | ||
2801 | // CheckHeartbeat(); | 2953 | CheckHeartbeat(); |
2802 | 2954 | ||
2803 | sp = GetScenePresence(client.AgentId); | 2955 | sp = GetScenePresence(client.AgentId); |
2804 | 2956 | ||
@@ -2816,6 +2968,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2816 | SubscribeToClientEvents(client); | 2968 | SubscribeToClientEvents(client); |
2817 | 2969 | ||
2818 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | 2970 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
2971 | InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
2972 | if (cof == null) | ||
2973 | sp.COF = UUID.Zero; | ||
2974 | else | ||
2975 | sp.COF = cof.ID; | ||
2976 | |||
2977 | m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); | ||
2819 | m_eventManager.TriggerOnNewPresence(sp); | 2978 | m_eventManager.TriggerOnNewPresence(sp); |
2820 | 2979 | ||
2821 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | 2980 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; |
@@ -2829,6 +2988,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2829 | // start the scripts again (since this is done in RezAttachments()). | 2988 | // start the scripts again (since this is done in RezAttachments()). |
2830 | // XXX: This is convoluted. | 2989 | // XXX: This is convoluted. |
2831 | sp.IsChildAgent = false; | 2990 | sp.IsChildAgent = false; |
2991 | sp.IsLoggingIn = true; | ||
2832 | 2992 | ||
2833 | // We leave a 5 second pause before attempting to rez attachments to avoid a clash with | 2993 | // We leave a 5 second pause before attempting to rez attachments to avoid a clash with |
2834 | // version 3 viewers that maybe doing their own attachment rezzing related to their current | 2994 | // version 3 viewers that maybe doing their own attachment rezzing related to their current |
@@ -2956,19 +3116,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2956 | // and the scene presence and the client, if they exist | 3116 | // and the scene presence and the client, if they exist |
2957 | try | 3117 | try |
2958 | { | 3118 | { |
2959 | // We need to wait for the client to make UDP contact first. | 3119 | ScenePresence sp = GetScenePresence(agentID); |
2960 | // It's the UDP contact that creates the scene presence | 3120 | |
2961 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2962 | if (sp != null) | 3121 | if (sp != null) |
2963 | { | 3122 | { |
2964 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3123 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2965 | |||
2966 | sp.ControllingClient.Close(); | 3124 | sp.ControllingClient.Close(); |
2967 | } | 3125 | } |
2968 | else | 3126 | |
2969 | { | ||
2970 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2971 | } | ||
2972 | // BANG! SLASH! | 3127 | // BANG! SLASH! |
2973 | m_authenticateHandler.RemoveCircuit(agentID); | 3128 | m_authenticateHandler.RemoveCircuit(agentID); |
2974 | 3129 | ||
@@ -3013,6 +3168,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3013 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3168 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
3014 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3169 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
3015 | 3170 | ||
3171 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3172 | |||
3016 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3173 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3017 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3174 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3018 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3175 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3069,6 +3226,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3069 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3226 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3070 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3227 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3071 | client.OnCopyInventoryItem += CopyInventoryItem; | 3228 | client.OnCopyInventoryItem += CopyInventoryItem; |
3229 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3072 | client.OnMoveInventoryItem += MoveInventoryItem; | 3230 | client.OnMoveInventoryItem += MoveInventoryItem; |
3073 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3231 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3074 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3232 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3140,6 +3298,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3140 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3298 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3141 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3299 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3142 | 3300 | ||
3301 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3302 | |||
3143 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3303 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3144 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3304 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3145 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3305 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3242,7 +3402,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3242 | /// </summary> | 3402 | /// </summary> |
3243 | /// <param name="agentId">The avatar's Unique ID</param> | 3403 | /// <param name="agentId">The avatar's Unique ID</param> |
3244 | /// <param name="client">The IClientAPI for the client</param> | 3404 | /// <param name="client">The IClientAPI for the client</param> |
3245 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3405 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3246 | { | 3406 | { |
3247 | if (EntityTransferModule != null) | 3407 | if (EntityTransferModule != null) |
3248 | { | 3408 | { |
@@ -3253,6 +3413,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3253 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3413 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3254 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3414 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3255 | } | 3415 | } |
3416 | return false; | ||
3256 | } | 3417 | } |
3257 | 3418 | ||
3258 | /// <summary> | 3419 | /// <summary> |
@@ -3362,6 +3523,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3362 | /// <param name="flags"></param> | 3523 | /// <param name="flags"></param> |
3363 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3524 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3364 | { | 3525 | { |
3526 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3527 | ScenePresence presence; | ||
3528 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3529 | { | ||
3530 | if (presence.Appearance != null) | ||
3531 | { | ||
3532 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3533 | } | ||
3534 | } | ||
3535 | |||
3365 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3536 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3366 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3537 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3367 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3538 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3463,7 +3634,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3463 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 3634 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3464 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 3635 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3465 | if (closeChildAgents && CapsModule != null) | 3636 | if (closeChildAgents && CapsModule != null) |
3466 | CapsModule.RemoveCaps(agentID); | 3637 | CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); |
3467 | 3638 | ||
3468 | // // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever | 3639 | // // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3469 | // // this method is doing is HORRIBLE!!! | 3640 | // // this method is doing is HORRIBLE!!! |
@@ -3499,6 +3670,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3499 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3670 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3500 | if (AgentTransactionsModule != null) | 3671 | if (AgentTransactionsModule != null) |
3501 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3672 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3673 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3502 | } | 3674 | } |
3503 | catch (Exception e) | 3675 | catch (Exception e) |
3504 | { | 3676 | { |
@@ -3691,15 +3863,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3691 | agent.firstname, agent.lastname, agent.Viewer); | 3863 | agent.firstname, agent.lastname, agent.Viewer); |
3692 | reason = "Access denied, your viewer is banned by the region owner"; | 3864 | reason = "Access denied, your viewer is banned by the region owner"; |
3693 | return false; | 3865 | return false; |
3694 | } | 3866 | } |
3695 | 3867 | ||
3696 | ILandObject land; | 3868 | ScenePresence sp = GetScenePresence(agent.AgentID); |
3697 | 3869 | ||
3698 | lock (agent) | 3870 | // If we have noo presence here or if that presence is a zombie root |
3871 | // presence that will be kicled, we need a new CAPS object. | ||
3872 | if (sp == null || (sp != null && !sp.IsChildAgent)) | ||
3699 | { | 3873 | { |
3700 | ScenePresence sp = GetScenePresence(agent.AgentID); | 3874 | if (CapsModule != null) |
3701 | 3875 | { | |
3702 | if (sp != null && !sp.IsChildAgent) | 3876 | lock (agent) |
3877 | { | ||
3878 | CapsModule.SetAgentCapsSeeds(agent); | ||
3879 | CapsModule.CreateCaps(agent.AgentID, agent.circuitcode); | ||
3880 | } | ||
3881 | } | ||
3882 | } | ||
3883 | |||
3884 | if (sp != null) | ||
3885 | { | ||
3886 | if (!sp.IsChildAgent) | ||
3703 | { | 3887 | { |
3704 | // We have a zombie from a crashed session. | 3888 | // We have a zombie from a crashed session. |
3705 | // Or the same user is trying to be root twice here, won't work. | 3889 | // Or the same user is trying to be root twice here, won't work. |
@@ -3707,22 +3891,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3707 | m_log.WarnFormat( | 3891 | m_log.WarnFormat( |
3708 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | 3892 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", |
3709 | sp.Name, sp.UUID, RegionInfo.RegionName); | 3893 | sp.Name, sp.UUID, RegionInfo.RegionName); |
3710 | 3894 | ||
3711 | sp.ControllingClient.Close(true); | 3895 | sp.ControllingClient.Close(true, true); |
3712 | sp = null; | 3896 | sp = null; |
3713 | } | 3897 | } |
3714 | 3898 | } | |
3715 | land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | 3899 | |
3716 | 3900 | lock (agent) | |
3901 | { | ||
3717 | //On login test land permisions | 3902 | //On login test land permisions |
3718 | if (vialogin) | 3903 | if (vialogin) |
3719 | { | 3904 | { |
3720 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3905 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3906 | if (cache != null) | ||
3907 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3908 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3721 | { | 3909 | { |
3910 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3722 | return false; | 3911 | return false; |
3723 | } | 3912 | } |
3724 | } | 3913 | } |
3725 | 3914 | ||
3726 | if (sp == null) // We don't have an [child] agent here already | 3915 | if (sp == null) // We don't have an [child] agent here already |
3727 | { | 3916 | { |
3728 | if (requirePresenceLookup) | 3917 | if (requirePresenceLookup) |
@@ -3731,54 +3920,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
3731 | { | 3920 | { |
3732 | if (!VerifyUserPresence(agent, out reason)) | 3921 | if (!VerifyUserPresence(agent, out reason)) |
3733 | return false; | 3922 | return false; |
3734 | } | 3923 | } catch (Exception e) |
3735 | catch (Exception e) | ||
3736 | { | 3924 | { |
3737 | m_log.ErrorFormat( | 3925 | m_log.ErrorFormat( |
3738 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); | 3926 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); |
3739 | |||
3740 | return false; | 3927 | return false; |
3741 | } | 3928 | } |
3742 | } | 3929 | } |
3743 | 3930 | ||
3744 | try | 3931 | try |
3745 | { | 3932 | { |
3746 | if (!AuthorizeUser(agent, out reason)) | 3933 | // Always check estate if this is a login. Always |
3747 | return false; | 3934 | // check if banned regions are to be blacked out. |
3935 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3936 | { | ||
3937 | if (!AuthorizeUser(agent, out reason)) | ||
3938 | { | ||
3939 | return false; | ||
3940 | } | ||
3941 | } | ||
3748 | } | 3942 | } |
3749 | catch (Exception e) | 3943 | catch (Exception e) |
3750 | { | 3944 | { |
3751 | m_log.ErrorFormat( | 3945 | m_log.ErrorFormat( |
3752 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3946 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
3753 | |||
3754 | return false; | 3947 | return false; |
3755 | } | 3948 | } |
3756 | 3949 | ||
3757 | m_log.InfoFormat( | 3950 | m_log.InfoFormat( |
3758 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 3951 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3759 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3952 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3760 | agent.AgentID, agent.circuitcode); | 3953 | agent.AgentID, agent.circuitcode); |
3761 | 3954 | ||
3762 | if (CapsModule != null) | ||
3763 | { | ||
3764 | CapsModule.SetAgentCapsSeeds(agent); | ||
3765 | CapsModule.CreateCaps(agent.AgentID); | ||
3766 | } | ||
3767 | } | 3955 | } |
3768 | else | 3956 | else |
3769 | { | 3957 | { |
3770 | // Let the SP know how we got here. This has a lot of interesting | 3958 | // Let the SP know how we got here. This has a lot of interesting |
3771 | // uses down the line. | 3959 | // uses down the line. |
3772 | sp.TeleportFlags = (TPFlags)teleportFlags; | 3960 | sp.TeleportFlags = (TPFlags)teleportFlags; |
3773 | 3961 | ||
3774 | if (sp.IsChildAgent) | 3962 | if (sp.IsChildAgent) |
3775 | { | 3963 | { |
3776 | m_log.DebugFormat( | 3964 | m_log.DebugFormat( |
3777 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3965 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
3778 | agent.AgentID, RegionInfo.RegionName); | 3966 | agent.AgentID, RegionInfo.RegionName); |
3779 | 3967 | ||
3780 | sp.AdjustKnownSeeds(); | 3968 | sp.AdjustKnownSeeds(); |
3781 | 3969 | ||
3782 | if (CapsModule != null) | 3970 | if (CapsModule != null) |
3783 | CapsModule.SetAgentCapsSeeds(agent); | 3971 | CapsModule.SetAgentCapsSeeds(agent); |
3784 | } | 3972 | } |
@@ -3789,6 +3977,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3789 | agent.teleportFlags = teleportFlags; | 3977 | agent.teleportFlags = teleportFlags; |
3790 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3978 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3791 | 3979 | ||
3980 | if (CapsModule != null) | ||
3981 | { | ||
3982 | CapsModule.ActivateCaps(agent.circuitcode); | ||
3983 | } | ||
3984 | |||
3792 | if (vialogin) | 3985 | if (vialogin) |
3793 | { | 3986 | { |
3794 | // CleanDroppedAttachments(); | 3987 | // CleanDroppedAttachments(); |
@@ -3880,6 +4073,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3880 | } | 4073 | } |
3881 | 4074 | ||
3882 | // Honor parcel landing type and position. | 4075 | // Honor parcel landing type and position. |
4076 | /* | ||
4077 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3883 | if (land != null) | 4078 | if (land != null) |
3884 | { | 4079 | { |
3885 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4080 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3887,25 +4082,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
3887 | agent.startpos = land.LandData.UserLocation; | 4082 | agent.startpos = land.LandData.UserLocation; |
3888 | } | 4083 | } |
3889 | } | 4084 | } |
4085 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3890 | } | 4086 | } |
3891 | 4087 | ||
3892 | return true; | 4088 | return true; |
3893 | } | 4089 | } |
3894 | 4090 | ||
3895 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 4091 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3896 | { | 4092 | { |
3897 | bool banned = land.IsBannedFromLand(agent.AgentID); | 4093 | if (posX < 0) |
3898 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 4094 | posX = 0; |
4095 | else if (posX >= 256) | ||
4096 | posX = 255.999f; | ||
4097 | if (posY < 0) | ||
4098 | posY = 0; | ||
4099 | else if (posY >= 256) | ||
4100 | posY = 255.999f; | ||
4101 | |||
4102 | reason = String.Empty; | ||
4103 | if (Permissions.IsGod(agentID)) | ||
4104 | return true; | ||
4105 | |||
4106 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
4107 | if (land == null) | ||
4108 | return false; | ||
4109 | |||
4110 | bool banned = land.IsBannedFromLand(agentID); | ||
4111 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3899 | 4112 | ||
3900 | if (banned || restricted) | 4113 | if (banned || restricted) |
3901 | { | 4114 | { |
3902 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 4115 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3903 | if (nearestParcel != null) | 4116 | if (nearestParcel != null) |
3904 | { | 4117 | { |
3905 | //Move agent to nearest allowed | 4118 | //Move agent to nearest allowed |
3906 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 4119 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3907 | agent.startpos.X = newPosition.X; | 4120 | posX = newPosition.X; |
3908 | agent.startpos.Y = newPosition.Y; | 4121 | posY = newPosition.Y; |
3909 | } | 4122 | } |
3910 | else | 4123 | else |
3911 | { | 4124 | { |
@@ -3967,7 +4180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3967 | 4180 | ||
3968 | if (!m_strictAccessControl) return true; | 4181 | if (!m_strictAccessControl) return true; |
3969 | if (Permissions.IsGod(agent.AgentID)) return true; | 4182 | if (Permissions.IsGod(agent.AgentID)) return true; |
3970 | 4183 | ||
3971 | if (AuthorizationService != null) | 4184 | if (AuthorizationService != null) |
3972 | { | 4185 | { |
3973 | if (!AuthorizationService.IsAuthorizedForRegion( | 4186 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3982,7 +4195,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3982 | 4195 | ||
3983 | if (RegionInfo.EstateSettings != null) | 4196 | if (RegionInfo.EstateSettings != null) |
3984 | { | 4197 | { |
3985 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4198 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3986 | { | 4199 | { |
3987 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4200 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3988 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4201 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4172,6 +4385,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4172 | 4385 | ||
4173 | // XPTO: if this agent is not allowed here as root, always return false | 4386 | // XPTO: if this agent is not allowed here as root, always return false |
4174 | 4387 | ||
4388 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4389 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4390 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4391 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4392 | { | ||
4393 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4394 | return false; | ||
4395 | } | ||
4396 | |||
4175 | // TODO: This check should probably be in QueryAccess(). | 4397 | // TODO: This check should probably be in QueryAccess(). |
4176 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4398 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4177 | if (nearestParcel == null) | 4399 | if (nearestParcel == null) |
@@ -4236,7 +4458,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4236 | /// <param name='agentID'></param> | 4458 | /// <param name='agentID'></param> |
4237 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4459 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4238 | { | 4460 | { |
4239 | int ntimes = 10; | 4461 | int ntimes = 30; |
4240 | ScenePresence sp = null; | 4462 | ScenePresence sp = null; |
4241 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4463 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4242 | Thread.Sleep(1000); | 4464 | Thread.Sleep(1000); |
@@ -4266,6 +4488,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4266 | return false; | 4488 | return false; |
4267 | } | 4489 | } |
4268 | 4490 | ||
4491 | public bool IncomingCloseAgent(UUID agentID) | ||
4492 | { | ||
4493 | return IncomingCloseAgent(agentID, false); | ||
4494 | } | ||
4495 | |||
4496 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4497 | { | ||
4498 | return IncomingCloseAgent(agentID, true); | ||
4499 | } | ||
4500 | |||
4269 | /// <summary> | 4501 | /// <summary> |
4270 | /// Tell a single agent to disconnect from the region. | 4502 | /// Tell a single agent to disconnect from the region. |
4271 | /// </summary> | 4503 | /// </summary> |
@@ -4281,7 +4513,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4281 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4513 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4282 | if (presence != null) | 4514 | if (presence != null) |
4283 | { | 4515 | { |
4284 | presence.ControllingClient.Close(force); | 4516 | presence.ControllingClient.Close(force, force); |
4285 | return true; | 4517 | return true; |
4286 | } | 4518 | } |
4287 | 4519 | ||
@@ -4914,7 +5146,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4914 | { | 5146 | { |
4915 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5147 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
4916 | { | 5148 | { |
4917 | if (grp.RootPart.Expires <= DateTime.Now) | 5149 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
4918 | DeleteSceneObject(grp, false); | 5150 | DeleteSceneObject(grp, false); |
4919 | } | 5151 | } |
4920 | } | 5152 | } |
@@ -4928,35 +5160,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4928 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5160 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4929 | } | 5161 | } |
4930 | 5162 | ||
4931 | public int GetHealth() | 5163 | public int GetHealth(out int flags, out string message) |
4932 | { | 5164 | { |
4933 | // Returns: | 5165 | // Returns: |
4934 | // 1 = sim is up and accepting http requests. The heartbeat has | 5166 | // 1 = sim is up and accepting http requests. The heartbeat has |
4935 | // stopped and the sim is probably locked up, but a remote | 5167 | // stopped and the sim is probably locked up, but a remote |
4936 | // admin restart may succeed | 5168 | // admin restart may succeed |
4937 | // | 5169 | // |
4938 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5170 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4939 | // usable for people within and logins _may_ work | 5171 | // usable for people within |
5172 | // | ||
5173 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5174 | // unstable and will not accept new logins | ||
4940 | // | 5175 | // |
4941 | // 3 = We have seen a new user enter within the past 4 minutes | 5176 | // 4 = Sim is up and both packet threads are running. Sim is |
5177 | // likely usable | ||
5178 | // | ||
5179 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4942 | // which can be seen as positive confirmation of sim health | 5180 | // which can be seen as positive confirmation of sim health |
4943 | // | 5181 | // |
5182 | |||
5183 | flags = 0; | ||
5184 | message = String.Empty; | ||
5185 | |||
5186 | CheckHeartbeat(); | ||
5187 | |||
5188 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5189 | { | ||
5190 | // We're still starting | ||
5191 | // 0 means "in startup", it can't happen another way, since | ||
5192 | // to get here, we must be able to accept http connections | ||
5193 | return 0; | ||
5194 | } | ||
5195 | |||
4944 | int health=1; // Start at 1, means we're up | 5196 | int health=1; // Start at 1, means we're up |
4945 | 5197 | ||
4946 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5198 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4947 | health += 1; | 5199 | { |
5200 | health+=1; | ||
5201 | flags |= 1; | ||
5202 | } | ||
5203 | |||
5204 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5205 | { | ||
5206 | health+=1; | ||
5207 | flags |= 2; | ||
5208 | } | ||
5209 | |||
5210 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5211 | { | ||
5212 | health+=1; | ||
5213 | flags |= 4; | ||
5214 | } | ||
4948 | else | 5215 | else |
5216 | { | ||
5217 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5218 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5219 | proc.EnableRaisingEvents=false; | ||
5220 | proc.StartInfo.FileName = "/bin/kill"; | ||
5221 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5222 | proc.Start(); | ||
5223 | proc.WaitForExit(); | ||
5224 | Thread.Sleep(1000); | ||
5225 | Environment.Exit(1); | ||
5226 | } | ||
5227 | |||
5228 | if (flags != 7) | ||
4949 | return health; | 5229 | return health; |
4950 | 5230 | ||
4951 | // A login in the last 4 mins? We can't be doing too badly | 5231 | // A login in the last 4 mins? We can't be doing too badly |
4952 | // | 5232 | // |
4953 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5233 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4954 | health++; | 5234 | health++; |
4955 | else | 5235 | else |
4956 | return health; | 5236 | return health; |
4957 | 5237 | ||
4958 | // CheckHeartbeat(); | ||
4959 | |||
4960 | return health; | 5238 | return health; |
4961 | } | 5239 | } |
4962 | 5240 | ||
@@ -5044,7 +5322,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5044 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5322 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5045 | if (wasUsingPhysics) | 5323 | if (wasUsingPhysics) |
5046 | { | 5324 | { |
5047 | 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 | 5325 | 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 |
5048 | } | 5326 | } |
5049 | } | 5327 | } |
5050 | 5328 | ||
@@ -5143,14 +5421,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5143 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5421 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5144 | } | 5422 | } |
5145 | 5423 | ||
5146 | // private void CheckHeartbeat() | 5424 | private void CheckHeartbeat() |
5147 | // { | 5425 | { |
5148 | // if (m_firstHeartbeat) | 5426 | if (m_firstHeartbeat) |
5149 | // return; | 5427 | return; |
5150 | // | 5428 | |
5151 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5429 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5152 | // StartTimer(); | 5430 | Start(); |
5153 | // } | 5431 | } |
5154 | 5432 | ||
5155 | public override ISceneObject DeserializeObject(string representation) | 5433 | public override ISceneObject DeserializeObject(string representation) |
5156 | { | 5434 | { |
@@ -5162,9 +5440,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5162 | get { return m_allowScriptCrossings; } | 5440 | get { return m_allowScriptCrossings; } |
5163 | } | 5441 | } |
5164 | 5442 | ||
5165 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5443 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5166 | { | 5444 | { |
5167 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5445 | return GetNearestAllowedPosition(avatar, null); |
5446 | } | ||
5447 | |||
5448 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
5449 | { | ||
5450 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
5168 | 5451 | ||
5169 | if (nearestParcel != null) | 5452 | if (nearestParcel != null) |
5170 | { | 5453 | { |
@@ -5173,10 +5456,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5173 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5456 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5174 | if (nearestPoint != null) | 5457 | if (nearestPoint != null) |
5175 | { | 5458 | { |
5176 | // m_log.DebugFormat( | 5459 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
5177 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
5178 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
5179 | |||
5180 | return nearestPoint.Value; | 5460 | return nearestPoint.Value; |
5181 | } | 5461 | } |
5182 | 5462 | ||
@@ -5186,17 +5466,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
5186 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5466 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5187 | if (nearestPoint != null) | 5467 | if (nearestPoint != null) |
5188 | { | 5468 | { |
5189 | // m_log.DebugFormat( | 5469 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
5190 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
5191 | |||
5192 | return nearestPoint.Value; | 5470 | return nearestPoint.Value; |
5193 | } | 5471 | } |
5194 | 5472 | ||
5195 | //Ultimate backup if we have no idea where they are | 5473 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
5196 | // m_log.DebugFormat( | 5474 | if (dest != excludeParcel) |
5197 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5475 | { |
5476 | // Ultimate backup if we have no idea where they are and | ||
5477 | // the last allowed position was in another parcel | ||
5478 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5479 | return avatar.lastKnownAllowedPosition; | ||
5480 | } | ||
5198 | 5481 | ||
5199 | return avatar.lastKnownAllowedPosition; | 5482 | // else fall through to region edge |
5200 | } | 5483 | } |
5201 | 5484 | ||
5202 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5485 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -5230,13 +5513,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5230 | 5513 | ||
5231 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5514 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
5232 | { | 5515 | { |
5516 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5517 | } | ||
5518 | |||
5519 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5520 | { | ||
5233 | List<ILandObject> all = AllParcels(); | 5521 | List<ILandObject> all = AllParcels(); |
5234 | float minParcelDistance = float.MaxValue; | 5522 | float minParcelDistance = float.MaxValue; |
5235 | ILandObject nearestParcel = null; | 5523 | ILandObject nearestParcel = null; |
5236 | 5524 | ||
5237 | foreach (var parcel in all) | 5525 | foreach (var parcel in all) |
5238 | { | 5526 | { |
5239 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5527 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
5240 | { | 5528 | { |
5241 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5529 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
5242 | if (parcelDistance < minParcelDistance) | 5530 | if (parcelDistance < minParcelDistance) |
@@ -5452,7 +5740,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5452 | mapModule.GenerateMaptile(); | 5740 | mapModule.GenerateMaptile(); |
5453 | } | 5741 | } |
5454 | 5742 | ||
5455 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5743 | // public void CleanDroppedAttachments() |
5744 | // { | ||
5745 | // List<SceneObjectGroup> objectsToDelete = | ||
5746 | // new List<SceneObjectGroup>(); | ||
5747 | // | ||
5748 | // lock (m_cleaningAttachments) | ||
5749 | // { | ||
5750 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5751 | // { | ||
5752 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5753 | // { | ||
5754 | // UUID agentID = grp.OwnerID; | ||
5755 | // if (agentID == UUID.Zero) | ||
5756 | // { | ||
5757 | // objectsToDelete.Add(grp); | ||
5758 | // return; | ||
5759 | // } | ||
5760 | // | ||
5761 | // ScenePresence sp = GetScenePresence(agentID); | ||
5762 | // if (sp == null) | ||
5763 | // { | ||
5764 | // objectsToDelete.Add(grp); | ||
5765 | // return; | ||
5766 | // } | ||
5767 | // } | ||
5768 | // }); | ||
5769 | // } | ||
5770 | // | ||
5771 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5772 | // { | ||
5773 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5774 | // DeleteSceneObject(grp, true); | ||
5775 | // } | ||
5776 | // } | ||
5777 | |||
5778 | public void ThreadAlive(int threadCode) | ||
5779 | { | ||
5780 | switch(threadCode) | ||
5781 | { | ||
5782 | case 1: // Incoming | ||
5783 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5784 | break; | ||
5785 | case 2: // Incoming | ||
5786 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5787 | break; | ||
5788 | } | ||
5789 | } | ||
5790 | |||
5791 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5456 | { | 5792 | { |
5457 | RegenerateMaptile(); | 5793 | RegenerateMaptile(); |
5458 | 5794 | ||
@@ -5480,6 +5816,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5480 | /// <returns></returns> | 5816 | /// <returns></returns> |
5481 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5817 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5482 | { | 5818 | { |
5819 | reason = "You are banned from the region"; | ||
5820 | |||
5483 | if (EntityTransferModule.IsInTransit(agentID)) | 5821 | if (EntityTransferModule.IsInTransit(agentID)) |
5484 | { | 5822 | { |
5485 | reason = "Agent is still in transit from this region"; | 5823 | reason = "Agent is still in transit from this region"; |
@@ -5491,6 +5829,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5491 | return false; | 5829 | return false; |
5492 | } | 5830 | } |
5493 | 5831 | ||
5832 | if (Permissions.IsGod(agentID)) | ||
5833 | { | ||
5834 | reason = String.Empty; | ||
5835 | return true; | ||
5836 | } | ||
5837 | |||
5494 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5838 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5495 | // However, the long term fix is to make sure root agent count is always accurate. | 5839 | // However, the long term fix is to make sure root agent count is always accurate. |
5496 | m_sceneGraph.RecalculateStats(); | 5840 | m_sceneGraph.RecalculateStats(); |
@@ -5511,6 +5855,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5511 | } | 5855 | } |
5512 | } | 5856 | } |
5513 | 5857 | ||
5858 | ScenePresence presence = GetScenePresence(agentID); | ||
5859 | IClientAPI client = null; | ||
5860 | AgentCircuitData aCircuit = null; | ||
5861 | |||
5862 | if (presence != null) | ||
5863 | { | ||
5864 | client = presence.ControllingClient; | ||
5865 | if (client != null) | ||
5866 | aCircuit = client.RequestClientInfo(); | ||
5867 | } | ||
5868 | |||
5869 | // We may be called before there is a presence or a client. | ||
5870 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5871 | if (client == null) | ||
5872 | { | ||
5873 | aCircuit = new AgentCircuitData(); | ||
5874 | aCircuit.AgentID = agentID; | ||
5875 | aCircuit.firstname = String.Empty; | ||
5876 | aCircuit.lastname = String.Empty; | ||
5877 | } | ||
5878 | |||
5879 | try | ||
5880 | { | ||
5881 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5882 | { | ||
5883 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5884 | return false; | ||
5885 | } | ||
5886 | } | ||
5887 | catch (Exception e) | ||
5888 | { | ||
5889 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5890 | return false; | ||
5891 | } | ||
5892 | |||
5514 | if (position == Vector3.Zero) // Teleport | 5893 | if (position == Vector3.Zero) // Teleport |
5515 | { | 5894 | { |
5516 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5895 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5544,13 +5923,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5544 | } | 5923 | } |
5545 | } | 5924 | } |
5546 | } | 5925 | } |
5926 | |||
5927 | float posX = 128.0f; | ||
5928 | float posY = 128.0f; | ||
5929 | |||
5930 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5931 | { | ||
5932 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5933 | return false; | ||
5934 | } | ||
5935 | } | ||
5936 | else // Walking | ||
5937 | { | ||
5938 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5939 | if (land == null) | ||
5940 | return false; | ||
5941 | |||
5942 | bool banned = land.IsBannedFromLand(agentID); | ||
5943 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5944 | |||
5945 | if (banned || restricted) | ||
5946 | return false; | ||
5547 | } | 5947 | } |
5548 | 5948 | ||
5549 | reason = String.Empty; | 5949 | reason = String.Empty; |
5550 | return true; | 5950 | return true; |
5551 | } | 5951 | } |
5552 | 5952 | ||
5553 | /// <summary> | 5953 | public void StartTimerWatchdog() |
5954 | { | ||
5955 | m_timerWatchdog.Interval = 1000; | ||
5956 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5957 | m_timerWatchdog.AutoReset = true; | ||
5958 | m_timerWatchdog.Start(); | ||
5959 | } | ||
5960 | |||
5961 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5962 | { | ||
5963 | CheckHeartbeat(); | ||
5964 | } | ||
5965 | |||
5554 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5966 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5555 | /// autopilot that moves an avatar to a sit target!. | 5967 | /// autopilot that moves an avatar to a sit target!. |
5556 | /// </summary> | 5968 | /// </summary> |
@@ -5629,6 +6041,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5629 | return m_SpawnPoint - 1; | 6041 | return m_SpawnPoint - 1; |
5630 | } | 6042 | } |
5631 | 6043 | ||
6044 | private void HandleGcCollect(string module, string[] args) | ||
6045 | { | ||
6046 | GC.Collect(); | ||
6047 | } | ||
6048 | |||
5632 | /// <summary> | 6049 | /// <summary> |
5633 | /// Wrappers to get physics modules retrieve assets. | 6050 | /// Wrappers to get physics modules retrieve assets. |
5634 | /// </summary> | 6051 | /// </summary> |