diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 700 |
1 files changed, 545 insertions, 155 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index de3978c..ce055d3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -226,8 +226,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | // TODO: need to figure out how allow client agents but deny | 226 | // TODO: need to figure out how allow client agents but deny |
227 | // root agents when ACL denies access to root agent | 227 | // root agents when ACL denies access to root agent |
228 | public bool m_strictAccessControl = true; | 228 | public bool m_strictAccessControl = true; |
229 | 229 | public bool m_seeIntoBannedRegion = false; | |
230 | public int MaxUndoCount { get; set; } | 230 | public int MaxUndoCount = 5; |
231 | 231 | ||
232 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 232 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
233 | public bool LoginLock = false; | 233 | public bool LoginLock = false; |
@@ -243,11 +243,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
243 | 243 | ||
244 | protected int m_splitRegionID; | 244 | protected int m_splitRegionID; |
245 | protected Timer m_restartWaitTimer = new Timer(); | 245 | protected Timer m_restartWaitTimer = new Timer(); |
246 | protected Timer m_timerWatchdog = new Timer(); | ||
246 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 247 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
247 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 248 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
248 | protected string m_simulatorVersion = "OpenSimulator Server"; | 249 | protected string m_simulatorVersion = "OpenSimulator Server"; |
249 | protected AgentCircuitManager m_authenticateHandler; | 250 | protected AgentCircuitManager m_authenticateHandler; |
250 | protected SceneCommunicationService m_sceneGridService; | 251 | protected SceneCommunicationService m_sceneGridService; |
252 | protected ISnmpModule m_snmpService = null; | ||
251 | 253 | ||
252 | protected ISimulationDataService m_SimulationDataService; | 254 | protected ISimulationDataService m_SimulationDataService; |
253 | protected IEstateDataService m_EstateDataService; | 255 | protected IEstateDataService m_EstateDataService; |
@@ -310,8 +312,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
310 | private int m_update_presences = 1; // Update scene presence movements | 312 | private int m_update_presences = 1; // Update scene presence movements |
311 | private int m_update_events = 1; | 313 | private int m_update_events = 1; |
312 | private int m_update_backup = 200; | 314 | private int m_update_backup = 200; |
313 | private int m_update_terrain = 50; | 315 | private int m_update_terrain = 1000; |
314 | // private int m_update_land = 1; | 316 | private int m_update_land = 10; |
315 | private int m_update_coarse_locations = 50; | 317 | private int m_update_coarse_locations = 50; |
316 | 318 | ||
317 | private int agentMS; | 319 | private int agentMS; |
@@ -324,13 +326,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
324 | private int backupMS; | 326 | private int backupMS; |
325 | private int terrainMS; | 327 | private int terrainMS; |
326 | private int landMS; | 328 | private int landMS; |
327 | private int spareMS; | ||
328 | 329 | ||
329 | /// <summary> | 330 | /// <summary> |
330 | /// Tick at which the last frame was processed. | 331 | /// Tick at which the last frame was processed. |
331 | /// </summary> | 332 | /// </summary> |
332 | private int m_lastFrameTick; | 333 | private int m_lastFrameTick; |
333 | 334 | ||
335 | public bool CombineRegions = false; | ||
334 | /// <summary> | 336 | /// <summary> |
335 | /// Tick at which the last maintenance run occurred. | 337 | /// Tick at which the last maintenance run occurred. |
336 | /// </summary> | 338 | /// </summary> |
@@ -350,7 +352,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 352 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
351 | private volatile bool m_backingup; | 353 | private volatile bool m_backingup; |
352 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 354 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
353 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 355 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
354 | 356 | ||
355 | private string m_defaultScriptEngine; | 357 | private string m_defaultScriptEngine; |
356 | 358 | ||
@@ -359,6 +361,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | /// </summary> | 361 | /// </summary> |
360 | private int m_LastLogin; | 362 | private int m_LastLogin; |
361 | 363 | ||
364 | private int m_lastIncoming; | ||
365 | private int m_lastOutgoing; | ||
366 | private int m_hbRestarts = 0; | ||
367 | |||
368 | |||
362 | /// <summary> | 369 | /// <summary> |
363 | /// Thread that runs the scene loop. | 370 | /// Thread that runs the scene loop. |
364 | /// </summary> | 371 | /// </summary> |
@@ -399,7 +406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
399 | private volatile bool m_active; | 406 | private volatile bool m_active; |
400 | 407 | ||
401 | // private int m_lastUpdate; | 408 | // private int m_lastUpdate; |
402 | // private bool m_firstHeartbeat = true; | 409 | private bool m_firstHeartbeat = true; |
403 | 410 | ||
404 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 411 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
405 | private bool m_reprioritizationEnabled = true; | 412 | private bool m_reprioritizationEnabled = true; |
@@ -443,6 +450,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
443 | get { return m_sceneGridService; } | 450 | get { return m_sceneGridService; } |
444 | } | 451 | } |
445 | 452 | ||
453 | public ISnmpModule SnmpService | ||
454 | { | ||
455 | get | ||
456 | { | ||
457 | if (m_snmpService == null) | ||
458 | { | ||
459 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
460 | } | ||
461 | |||
462 | return m_snmpService; | ||
463 | } | ||
464 | } | ||
465 | |||
446 | public ISimulationDataService SimulationDataService | 466 | public ISimulationDataService SimulationDataService |
447 | { | 467 | { |
448 | get | 468 | get |
@@ -735,6 +755,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
735 | m_SimulationDataService = simDataService; | 755 | m_SimulationDataService = simDataService; |
736 | m_EstateDataService = estateDataService; | 756 | m_EstateDataService = estateDataService; |
737 | m_regionHandle = RegionInfo.RegionHandle; | 757 | m_regionHandle = RegionInfo.RegionHandle; |
758 | m_lastIncoming = 0; | ||
759 | m_lastOutgoing = 0; | ||
738 | 760 | ||
739 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 761 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
740 | m_asyncSceneObjectDeleter.Enabled = true; | 762 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -828,7 +850,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
828 | 850 | ||
829 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 851 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
830 | 852 | ||
831 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 853 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
832 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 854 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
833 | if (!UseBackup) | 855 | if (!UseBackup) |
834 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 856 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -836,10 +858,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
836 | //Animation states | 858 | //Animation states |
837 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 859 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
838 | 860 | ||
839 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 861 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
840 | 862 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | |
841 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
842 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
843 | 863 | ||
844 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 864 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
845 | if (RegionInfo.NonphysPrimMin > 0) | 865 | if (RegionInfo.NonphysPrimMin > 0) |
@@ -860,11 +880,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
860 | } | 880 | } |
861 | 881 | ||
862 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 882 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
883 | |||
863 | if (RegionInfo.PhysPrimMax > 0) | 884 | if (RegionInfo.PhysPrimMax > 0) |
864 | { | 885 | { |
865 | m_maxPhys = RegionInfo.PhysPrimMax; | 886 | m_maxPhys = RegionInfo.PhysPrimMax; |
866 | } | 887 | } |
867 | 888 | ||
889 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
890 | if (RegionInfo.LinksetCapacity > 0) | ||
891 | { | ||
892 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
893 | } | ||
894 | |||
895 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
896 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
897 | |||
868 | // Here, if clamping is requested in either global or | 898 | // Here, if clamping is requested in either global or |
869 | // local config, it will be used | 899 | // local config, it will be used |
870 | // | 900 | // |
@@ -874,13 +904,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
874 | m_clampPrimSize = true; | 904 | m_clampPrimSize = true; |
875 | } | 905 | } |
876 | 906 | ||
877 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 907 | 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); | 908 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
885 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 909 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
886 | m_dontPersistBefore = | 910 | m_dontPersistBefore = |
@@ -891,11 +915,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
891 | m_persistAfter *= 10000000; | 915 | m_persistAfter *= 10000000; |
892 | 916 | ||
893 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 917 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
894 | 918 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
895 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
896 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
897 | 919 | ||
898 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 920 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
921 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
922 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
899 | 923 | ||
900 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 924 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
901 | if (m_generateMaptiles) | 925 | if (m_generateMaptiles) |
@@ -928,7 +952,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
928 | string grant = startupConfig.GetString("AllowedClients", String.Empty); | 952 | string grant = startupConfig.GetString("AllowedClients", String.Empty); |
929 | if (grant.Length > 0) | 953 | if (grant.Length > 0) |
930 | { | 954 | { |
931 | foreach (string viewer in grant.Split('|')) | 955 | foreach (string viewer in grant.Split(',')) |
932 | { | 956 | { |
933 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 957 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
934 | } | 958 | } |
@@ -937,7 +961,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
937 | grant = startupConfig.GetString("BannedClients", String.Empty); | 961 | grant = startupConfig.GetString("BannedClients", String.Empty); |
938 | if (grant.Length > 0) | 962 | if (grant.Length > 0) |
939 | { | 963 | { |
940 | foreach (string viewer in grant.Split('|')) | 964 | foreach (string viewer in grant.Split(',')) |
941 | { | 965 | { |
942 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 966 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
943 | } | 967 | } |
@@ -997,6 +1021,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
997 | StatsReporter = new SimStatsReporter(this); | 1021 | StatsReporter = new SimStatsReporter(this); |
998 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1022 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
999 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1023 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1024 | |||
1025 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1000 | } | 1026 | } |
1001 | 1027 | ||
1002 | public Scene(RegionInfo regInfo) : base(regInfo) | 1028 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1292,8 +1318,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1292 | // Stop all client threads. | 1318 | // Stop all client threads. |
1293 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1319 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1294 | 1320 | ||
1295 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1321 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1296 | EventManager.TriggerSceneShuttingDown(this); | 1322 | EventManager.TriggerSceneShuttingDown(this); |
1323 | |||
1324 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1325 | |||
1297 | Backup(false); | 1326 | Backup(false); |
1298 | m_sceneGraph.Close(); | 1327 | m_sceneGraph.Close(); |
1299 | 1328 | ||
@@ -1307,6 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1307 | // attempt to reference a null or disposed physics scene. | 1336 | // attempt to reference a null or disposed physics scene. |
1308 | if (PhysicsScene != null) | 1337 | if (PhysicsScene != null) |
1309 | { | 1338 | { |
1339 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1310 | PhysicsScene phys = PhysicsScene; | 1340 | PhysicsScene phys = PhysicsScene; |
1311 | // remove the physics engine from both Scene and SceneGraph | 1341 | // remove the physics engine from both Scene and SceneGraph |
1312 | PhysicsScene = null; | 1342 | PhysicsScene = null; |
@@ -1329,11 +1359,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1329 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1359 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1330 | if (m_heartbeatThread != null) | 1360 | if (m_heartbeatThread != null) |
1331 | { | 1361 | { |
1362 | m_hbRestarts++; | ||
1363 | if(m_hbRestarts > 10) | ||
1364 | Environment.Exit(1); | ||
1365 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1366 | |||
1367 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1368 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1369 | //proc.EnableRaisingEvents=false; | ||
1370 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1371 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1372 | //proc.Start(); | ||
1373 | //proc.WaitForExit(); | ||
1374 | //Thread.Sleep(1000); | ||
1375 | //Environment.Exit(1); | ||
1332 | m_heartbeatThread.Abort(); | 1376 | m_heartbeatThread.Abort(); |
1377 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1333 | m_heartbeatThread = null; | 1378 | m_heartbeatThread = null; |
1334 | } | 1379 | } |
1335 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1380 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1336 | 1381 | ||
1382 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1383 | |||
1384 | |||
1337 | m_heartbeatThread | 1385 | m_heartbeatThread |
1338 | = Watchdog.StartThread( | 1386 | = Watchdog.StartThread( |
1339 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1387 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1476,16 +1524,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1476 | endFrame = Frame + frames; | 1524 | endFrame = Frame + frames; |
1477 | 1525 | ||
1478 | float physicsFPS = 0f; | 1526 | float physicsFPS = 0f; |
1479 | int previousFrameTick, tmpMS; | 1527 | int tmpMS; |
1480 | int maintc = Util.EnvironmentTickCount(); | 1528 | int previousFrameTick; |
1529 | int maintc; | ||
1530 | int sleepMS; | ||
1531 | int framestart; | ||
1481 | 1532 | ||
1482 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1533 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1483 | { | 1534 | { |
1535 | framestart = Util.EnvironmentTickCount(); | ||
1484 | ++Frame; | 1536 | ++Frame; |
1485 | 1537 | ||
1486 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1538 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1487 | 1539 | ||
1488 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1540 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1489 | 1541 | ||
1490 | try | 1542 | try |
1491 | { | 1543 | { |
@@ -1537,6 +1589,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1537 | m_sceneGraph.UpdatePresences(); | 1589 | m_sceneGraph.UpdatePresences(); |
1538 | 1590 | ||
1539 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1591 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1592 | |||
1540 | 1593 | ||
1541 | // Delete temp-on-rez stuff | 1594 | // Delete temp-on-rez stuff |
1542 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1595 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1618,34 +1671,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1618 | 1671 | ||
1619 | Watchdog.UpdateThread(); | 1672 | Watchdog.UpdateThread(); |
1620 | 1673 | ||
1674 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1675 | |||
1676 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1677 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1678 | StatsReporter.AddFPS(1); | ||
1679 | |||
1680 | StatsReporter.addAgentMS(agentMS); | ||
1681 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1682 | StatsReporter.addOtherMS(otherMS); | ||
1683 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1684 | |||
1621 | previousFrameTick = m_lastFrameTick; | 1685 | previousFrameTick = m_lastFrameTick; |
1622 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1686 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1623 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1687 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1624 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1688 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1625 | 1689 | ||
1690 | m_firstHeartbeat = false; | ||
1691 | |||
1692 | sleepMS = Util.EnvironmentTickCount(); | ||
1693 | |||
1626 | if (tmpMS > 0) | 1694 | if (tmpMS > 0) |
1627 | { | ||
1628 | Thread.Sleep(tmpMS); | 1695 | Thread.Sleep(tmpMS); |
1629 | spareMS += tmpMS; | ||
1630 | } | ||
1631 | |||
1632 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | ||
1633 | maintc = Util.EnvironmentTickCount(); | ||
1634 | 1696 | ||
1635 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1697 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1698 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1699 | StatsReporter.addSleepMS(sleepMS); | ||
1700 | StatsReporter.addFrameMS(frameMS); | ||
1636 | 1701 | ||
1637 | // if (Frame%m_update_avatars == 0) | 1702 | // if (Frame%m_update_avatars == 0) |
1638 | // UpdateInWorldTime(); | 1703 | // UpdateInWorldTime(); |
1639 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1640 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1641 | StatsReporter.AddFPS(1); | ||
1642 | 1704 | ||
1643 | StatsReporter.addFrameMS(frameMS); | ||
1644 | StatsReporter.addAgentMS(agentMS); | ||
1645 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1646 | StatsReporter.addOtherMS(otherMS); | ||
1647 | StatsReporter.AddSpareMS(spareMS); | ||
1648 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1649 | 1705 | ||
1650 | // Optionally warn if a frame takes double the amount of time that it should. | 1706 | // Optionally warn if a frame takes double the amount of time that it should. |
1651 | if (DebugUpdates | 1707 | if (DebugUpdates |
@@ -1662,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1662 | public void AddGroupTarget(SceneObjectGroup grp) | 1718 | public void AddGroupTarget(SceneObjectGroup grp) |
1663 | { | 1719 | { |
1664 | lock (m_groupsWithTargets) | 1720 | lock (m_groupsWithTargets) |
1665 | m_groupsWithTargets[grp.UUID] = grp; | 1721 | m_groupsWithTargets[grp.UUID] = 0; |
1666 | } | 1722 | } |
1667 | 1723 | ||
1668 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1724 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1673,18 +1729,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1673 | 1729 | ||
1674 | private void CheckAtTargets() | 1730 | private void CheckAtTargets() |
1675 | { | 1731 | { |
1676 | List<SceneObjectGroup> objs = null; | 1732 | List<UUID> objs = null; |
1677 | 1733 | ||
1678 | lock (m_groupsWithTargets) | 1734 | lock (m_groupsWithTargets) |
1679 | { | 1735 | { |
1680 | if (m_groupsWithTargets.Count != 0) | 1736 | if (m_groupsWithTargets.Count != 0) |
1681 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1737 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1682 | } | 1738 | } |
1683 | 1739 | ||
1684 | if (objs != null) | 1740 | if (objs != null) |
1685 | { | 1741 | { |
1686 | foreach (SceneObjectGroup entry in objs) | 1742 | foreach (UUID entry in objs) |
1687 | entry.checkAtTargets(); | 1743 | { |
1744 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1745 | if (grp == null) | ||
1746 | m_groupsWithTargets.Remove(entry); | ||
1747 | else | ||
1748 | grp.checkAtTargets(); | ||
1749 | } | ||
1688 | } | 1750 | } |
1689 | } | 1751 | } |
1690 | 1752 | ||
@@ -1763,7 +1825,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1763 | msg.fromAgentName = "Server"; | 1825 | msg.fromAgentName = "Server"; |
1764 | msg.dialog = (byte)19; // Object msg | 1826 | msg.dialog = (byte)19; // Object msg |
1765 | msg.fromGroup = false; | 1827 | msg.fromGroup = false; |
1766 | msg.offline = (byte)0; | 1828 | msg.offline = (byte)1; |
1767 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1829 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1768 | msg.Position = Vector3.Zero; | 1830 | msg.Position = Vector3.Zero; |
1769 | msg.RegionID = RegionInfo.RegionID.Guid; | 1831 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1992,7 +2054,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1992 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2054 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
1993 | } | 2055 | } |
1994 | 2056 | ||
1995 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2057 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
1996 | { | 2058 | { |
1997 | if (PhysicsScene == null) | 2059 | if (PhysicsScene == null) |
1998 | return null; | 2060 | return null; |
@@ -2014,14 +2076,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2014 | /// <returns></returns> | 2076 | /// <returns></returns> |
2015 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2077 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2016 | { | 2078 | { |
2079 | |||
2080 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2081 | Vector3 wpos = Vector3.Zero; | ||
2082 | // Check for water surface intersection from above | ||
2083 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2084 | { | ||
2085 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2086 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2087 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2088 | wpos.Z = wheight; | ||
2089 | } | ||
2090 | |||
2017 | Vector3 pos = Vector3.Zero; | 2091 | Vector3 pos = Vector3.Zero; |
2018 | if (RayEndIsIntersection == (byte)1) | 2092 | if (RayEndIsIntersection == (byte)1) |
2019 | { | 2093 | { |
2020 | pos = RayEnd; | 2094 | pos = RayEnd; |
2021 | return pos; | ||
2022 | } | 2095 | } |
2023 | 2096 | else if (RayTargetID != UUID.Zero) | |
2024 | if (RayTargetID != UUID.Zero) | ||
2025 | { | 2097 | { |
2026 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2098 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2027 | 2099 | ||
@@ -2043,7 +2115,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2043 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2115 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2044 | 2116 | ||
2045 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2117 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2046 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2118 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2047 | float ScaleOffset = 0.5f; | 2119 | float ScaleOffset = 0.5f; |
2048 | 2120 | ||
2049 | // If we hit something | 2121 | // If we hit something |
@@ -2066,13 +2138,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2066 | //pos.Z -= 0.25F; | 2138 | //pos.Z -= 0.25F; |
2067 | 2139 | ||
2068 | } | 2140 | } |
2069 | |||
2070 | return pos; | ||
2071 | } | 2141 | } |
2072 | else | 2142 | else |
2073 | { | 2143 | { |
2074 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2144 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2075 | |||
2076 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2145 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2077 | 2146 | ||
2078 | // Un-comment the following line to print the raytrace results to the console. | 2147 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2081,13 +2150,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2081 | if (ei.HitTF) | 2150 | if (ei.HitTF) |
2082 | { | 2151 | { |
2083 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2152 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2084 | } else | 2153 | } |
2154 | else | ||
2085 | { | 2155 | { |
2086 | // fall back to our stupid functionality | 2156 | // fall back to our stupid functionality |
2087 | pos = RayEnd; | 2157 | pos = RayEnd; |
2088 | } | 2158 | } |
2089 | |||
2090 | return pos; | ||
2091 | } | 2159 | } |
2092 | } | 2160 | } |
2093 | else | 2161 | else |
@@ -2098,8 +2166,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2098 | //increase height so its above the ground. | 2166 | //increase height so its above the ground. |
2099 | //should be getting the normal of the ground at the rez point and using that? | 2167 | //should be getting the normal of the ground at the rez point and using that? |
2100 | pos.Z += scale.Z / 2f; | 2168 | pos.Z += scale.Z / 2f; |
2101 | return pos; | 2169 | // return pos; |
2102 | } | 2170 | } |
2171 | |||
2172 | // check against posible water intercept | ||
2173 | if (wpos.Z > pos.Z) pos = wpos; | ||
2174 | return pos; | ||
2103 | } | 2175 | } |
2104 | 2176 | ||
2105 | 2177 | ||
@@ -2190,12 +2262,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2190 | { | 2262 | { |
2191 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2263 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2192 | { | 2264 | { |
2265 | sceneObject.IsDeleted = false; | ||
2193 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2266 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2194 | return true; | 2267 | return true; |
2195 | } | 2268 | } |
2196 | 2269 | ||
2197 | return false; | 2270 | return false; |
2198 | |||
2199 | } | 2271 | } |
2200 | 2272 | ||
2201 | /// <summary> | 2273 | /// <summary> |
@@ -2287,6 +2359,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2287 | /// </summary> | 2359 | /// </summary> |
2288 | public void DeleteAllSceneObjects() | 2360 | public void DeleteAllSceneObjects() |
2289 | { | 2361 | { |
2362 | DeleteAllSceneObjects(false); | ||
2363 | } | ||
2364 | |||
2365 | /// <summary> | ||
2366 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2367 | /// </summary> | ||
2368 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2369 | { | ||
2370 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2290 | lock (Entities) | 2371 | lock (Entities) |
2291 | { | 2372 | { |
2292 | EntityBase[] entities = Entities.GetEntities(); | 2373 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2295,11 +2376,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2295 | if (e is SceneObjectGroup) | 2376 | if (e is SceneObjectGroup) |
2296 | { | 2377 | { |
2297 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2378 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2298 | if (!sog.IsAttachment) | 2379 | if (sog != null && !sog.IsAttachment) |
2299 | DeleteSceneObject((SceneObjectGroup)e, false); | 2380 | { |
2381 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2382 | { | ||
2383 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2384 | } | ||
2385 | else | ||
2386 | { | ||
2387 | toReturn.Add((SceneObjectGroup)e); | ||
2388 | } | ||
2389 | } | ||
2300 | } | 2390 | } |
2301 | } | 2391 | } |
2302 | } | 2392 | } |
2393 | if (toReturn.Count > 0) | ||
2394 | { | ||
2395 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2396 | } | ||
2303 | } | 2397 | } |
2304 | 2398 | ||
2305 | /// <summary> | 2399 | /// <summary> |
@@ -2334,6 +2428,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2334 | 2428 | ||
2335 | foreach (SceneObjectPart part in partList) | 2429 | foreach (SceneObjectPart part in partList) |
2336 | { | 2430 | { |
2431 | if (part.KeyframeMotion != null) | ||
2432 | { | ||
2433 | part.KeyframeMotion.Delete(); | ||
2434 | part.KeyframeMotion = null; | ||
2435 | } | ||
2436 | |||
2337 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) | 2437 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) |
2338 | { | 2438 | { |
2339 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? | 2439 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? |
@@ -2351,6 +2451,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2351 | } | 2451 | } |
2352 | 2452 | ||
2353 | group.DeleteGroupFromScene(silent); | 2453 | group.DeleteGroupFromScene(silent); |
2454 | if (!silent) | ||
2455 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2354 | 2456 | ||
2355 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2457 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2356 | } | 2458 | } |
@@ -2641,7 +2743,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2641 | // If the user is banned, we won't let any of their objects | 2743 | // If the user is banned, we won't let any of their objects |
2642 | // enter. Period. | 2744 | // enter. Period. |
2643 | // | 2745 | // |
2644 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2746 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2645 | { | 2747 | { |
2646 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2748 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2647 | return false; | 2749 | return false; |
@@ -2649,6 +2751,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2649 | 2751 | ||
2650 | if (newPosition != Vector3.Zero) | 2752 | if (newPosition != Vector3.Zero) |
2651 | newObject.RootPart.GroupPosition = newPosition; | 2753 | newObject.RootPart.GroupPosition = newPosition; |
2754 | if (newObject.RootPart.KeyframeMotion != null) | ||
2755 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2652 | 2756 | ||
2653 | if (!AddSceneObject(newObject)) | 2757 | if (!AddSceneObject(newObject)) |
2654 | { | 2758 | { |
@@ -2693,6 +2797,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2693 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2797 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2694 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2798 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2695 | { | 2799 | { |
2800 | if (sceneObject.OwnerID == UUID.Zero) | ||
2801 | { | ||
2802 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2803 | return false; | ||
2804 | } | ||
2805 | |||
2806 | // If the user is banned, we won't let any of their objects | ||
2807 | // enter. Period. | ||
2808 | // | ||
2809 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2810 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2811 | { | ||
2812 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2813 | |||
2814 | return false; | ||
2815 | } | ||
2816 | |||
2696 | // Force allocation of new LocalId | 2817 | // Force allocation of new LocalId |
2697 | // | 2818 | // |
2698 | SceneObjectPart[] parts = sceneObject.Parts; | 2819 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2726,16 +2847,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2726 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2847 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2727 | 2848 | ||
2728 | if (AttachmentsModule != null) | 2849 | if (AttachmentsModule != null) |
2729 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); | 2850 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); |
2730 | } | 2851 | } |
2731 | else | 2852 | else |
2732 | { | 2853 | { |
2854 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2733 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2855 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2734 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2856 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2735 | } | 2857 | } |
2858 | if (sceneObject.OwnerID == UUID.Zero) | ||
2859 | { | ||
2860 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2861 | return false; | ||
2862 | } | ||
2736 | } | 2863 | } |
2737 | else | 2864 | else |
2738 | { | 2865 | { |
2866 | if (sceneObject.OwnerID == UUID.Zero) | ||
2867 | { | ||
2868 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2869 | return false; | ||
2870 | } | ||
2739 | AddRestoredSceneObject(sceneObject, true, false); | 2871 | AddRestoredSceneObject(sceneObject, true, false); |
2740 | } | 2872 | } |
2741 | 2873 | ||
@@ -2752,6 +2884,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2752 | return 2; // StateSource.PrimCrossing | 2884 | return 2; // StateSource.PrimCrossing |
2753 | } | 2885 | } |
2754 | 2886 | ||
2887 | public int GetUserFlags(UUID user) | ||
2888 | { | ||
2889 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2890 | /* | ||
2891 | ScenePresence sp; | ||
2892 | if (TryGetScenePresence(user, out sp)) | ||
2893 | { | ||
2894 | return sp.UserFlags; | ||
2895 | } | ||
2896 | else | ||
2897 | { | ||
2898 | */ | ||
2899 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2900 | if (uac == null) | ||
2901 | return 0; | ||
2902 | return uac.UserFlags; | ||
2903 | //} | ||
2904 | } | ||
2755 | #endregion | 2905 | #endregion |
2756 | 2906 | ||
2757 | #region Add/Remove Avatar Methods | 2907 | #region Add/Remove Avatar Methods |
@@ -2784,7 +2934,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2784 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2934 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2785 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2935 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2786 | 2936 | ||
2787 | // CheckHeartbeat(); | 2937 | CheckHeartbeat(); |
2788 | 2938 | ||
2789 | sp = GetScenePresence(client.AgentId); | 2939 | sp = GetScenePresence(client.AgentId); |
2790 | 2940 | ||
@@ -2815,6 +2965,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2815 | // start the scripts again (since this is done in RezAttachments()). | 2965 | // start the scripts again (since this is done in RezAttachments()). |
2816 | // XXX: This is convoluted. | 2966 | // XXX: This is convoluted. |
2817 | sp.IsChildAgent = false; | 2967 | sp.IsChildAgent = false; |
2968 | sp.IsLoggingIn = true; | ||
2818 | 2969 | ||
2819 | if (AttachmentsModule != null) | 2970 | if (AttachmentsModule != null) |
2820 | Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); | 2971 | Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); |
@@ -2928,19 +3079,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2928 | // and the scene presence and the client, if they exist | 3079 | // and the scene presence and the client, if they exist |
2929 | try | 3080 | try |
2930 | { | 3081 | { |
2931 | // We need to wait for the client to make UDP contact first. | 3082 | ScenePresence sp = GetScenePresence(agentID); |
2932 | // It's the UDP contact that creates the scene presence | 3083 | |
2933 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2934 | if (sp != null) | 3084 | if (sp != null) |
2935 | { | 3085 | { |
2936 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3086 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2937 | |||
2938 | sp.ControllingClient.Close(); | 3087 | sp.ControllingClient.Close(); |
2939 | } | 3088 | } |
2940 | else | 3089 | |
2941 | { | ||
2942 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2943 | } | ||
2944 | // BANG! SLASH! | 3090 | // BANG! SLASH! |
2945 | m_authenticateHandler.RemoveCircuit(agentID); | 3091 | m_authenticateHandler.RemoveCircuit(agentID); |
2946 | 3092 | ||
@@ -2985,6 +3131,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2985 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3131 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2986 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3132 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2987 | 3133 | ||
3134 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3135 | |||
2988 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3136 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2989 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3137 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2990 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3138 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3041,6 +3189,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3041 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3189 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3042 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3190 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3043 | client.OnCopyInventoryItem += CopyInventoryItem; | 3191 | client.OnCopyInventoryItem += CopyInventoryItem; |
3192 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3044 | client.OnMoveInventoryItem += MoveInventoryItem; | 3193 | client.OnMoveInventoryItem += MoveInventoryItem; |
3045 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3194 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3046 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3195 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3112,6 +3261,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3112 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3261 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3113 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3262 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3114 | 3263 | ||
3264 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3265 | |||
3115 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3266 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3116 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3267 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3117 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3268 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3214,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3214 | /// </summary> | 3365 | /// </summary> |
3215 | /// <param name="agentId">The avatar's Unique ID</param> | 3366 | /// <param name="agentId">The avatar's Unique ID</param> |
3216 | /// <param name="client">The IClientAPI for the client</param> | 3367 | /// <param name="client">The IClientAPI for the client</param> |
3217 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3368 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3218 | { | 3369 | { |
3219 | if (EntityTransferModule != null) | 3370 | if (EntityTransferModule != null) |
3220 | { | 3371 | { |
@@ -3225,6 +3376,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3225 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3376 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3226 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3377 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3227 | } | 3378 | } |
3379 | return false; | ||
3228 | } | 3380 | } |
3229 | 3381 | ||
3230 | /// <summary> | 3382 | /// <summary> |
@@ -3334,6 +3486,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3334 | /// <param name="flags"></param> | 3486 | /// <param name="flags"></param> |
3335 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3487 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3336 | { | 3488 | { |
3489 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3490 | ScenePresence presence; | ||
3491 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3492 | { | ||
3493 | if (presence.Appearance != null) | ||
3494 | { | ||
3495 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3496 | } | ||
3497 | } | ||
3498 | |||
3337 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3499 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3338 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3500 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3339 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3501 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3471,6 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3471 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3633 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3472 | if (AgentTransactionsModule != null) | 3634 | if (AgentTransactionsModule != null) |
3473 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3635 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3636 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3474 | } | 3637 | } |
3475 | catch (Exception e) | 3638 | catch (Exception e) |
3476 | { | 3639 | { |
@@ -3663,38 +3826,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3663 | agent.firstname, agent.lastname, agent.Viewer); | 3826 | agent.firstname, agent.lastname, agent.Viewer); |
3664 | reason = "Access denied, your viewer is banned by the region owner"; | 3827 | reason = "Access denied, your viewer is banned by the region owner"; |
3665 | return false; | 3828 | return false; |
3666 | } | 3829 | } |
3830 | |||
3831 | |||
3832 | ScenePresence sp = GetScenePresence(agent.AgentID); | ||
3833 | |||
3834 | if (sp != null && !sp.IsChildAgent) | ||
3835 | { | ||
3836 | // We have a zombie from a crashed session. | ||
3837 | // Or the same user is trying to be root twice here, won't work. | ||
3838 | // Kill it. | ||
3839 | m_log.WarnFormat( | ||
3840 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | ||
3841 | sp.Name, sp.UUID, RegionInfo.RegionName); | ||
3667 | 3842 | ||
3668 | ILandObject land; | 3843 | sp.ControllingClient.Close(true, true); |
3844 | sp = null; | ||
3845 | } | ||
3669 | 3846 | ||
3670 | lock (agent) | 3847 | lock (agent) |
3671 | { | 3848 | { |
3672 | ScenePresence sp = GetScenePresence(agent.AgentID); | ||
3673 | |||
3674 | if (sp != null && !sp.IsChildAgent) | ||
3675 | { | ||
3676 | // We have a zombie from a crashed session. | ||
3677 | // Or the same user is trying to be root twice here, won't work. | ||
3678 | // Kill it. | ||
3679 | m_log.WarnFormat( | ||
3680 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | ||
3681 | sp.Name, sp.UUID, RegionInfo.RegionName); | ||
3682 | |||
3683 | sp.ControllingClient.Close(true); | ||
3684 | sp = null; | ||
3685 | } | ||
3686 | |||
3687 | land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3688 | |||
3689 | //On login test land permisions | 3849 | //On login test land permisions |
3690 | if (vialogin) | 3850 | if (vialogin) |
3691 | { | 3851 | { |
3692 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3852 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3853 | if (cache != null) | ||
3854 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3855 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3693 | { | 3856 | { |
3857 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3694 | return false; | 3858 | return false; |
3695 | } | 3859 | } |
3696 | } | 3860 | } |
3697 | 3861 | ||
3698 | if (sp == null) // We don't have an [child] agent here already | 3862 | if (sp == null) // We don't have an [child] agent here already |
3699 | { | 3863 | { |
3700 | if (requirePresenceLookup) | 3864 | if (requirePresenceLookup) |
@@ -3703,34 +3867,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3703 | { | 3867 | { |
3704 | if (!VerifyUserPresence(agent, out reason)) | 3868 | if (!VerifyUserPresence(agent, out reason)) |
3705 | return false; | 3869 | return false; |
3706 | } | 3870 | } catch (Exception e) |
3707 | catch (Exception e) | ||
3708 | { | 3871 | { |
3709 | m_log.ErrorFormat( | 3872 | m_log.ErrorFormat( |
3710 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); | 3873 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); |
3711 | |||
3712 | return false; | 3874 | return false; |
3713 | } | 3875 | } |
3714 | } | 3876 | } |
3715 | 3877 | ||
3716 | try | 3878 | try |
3717 | { | 3879 | { |
3718 | if (!AuthorizeUser(agent, out reason)) | 3880 | // Always check estate if this is a login. Always |
3719 | return false; | 3881 | // check if banned regions are to be blacked out. |
3882 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3883 | { | ||
3884 | if (!AuthorizeUser(agent, out reason)) | ||
3885 | return false; | ||
3886 | } | ||
3720 | } | 3887 | } |
3721 | catch (Exception e) | 3888 | catch (Exception e) |
3722 | { | 3889 | { |
3723 | m_log.ErrorFormat( | 3890 | m_log.ErrorFormat( |
3724 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3891 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
3725 | |||
3726 | return false; | 3892 | return false; |
3727 | } | 3893 | } |
3728 | 3894 | ||
3729 | m_log.InfoFormat( | 3895 | m_log.InfoFormat( |
3730 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 3896 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3731 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3897 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3732 | agent.AgentID, agent.circuitcode); | 3898 | agent.AgentID, agent.circuitcode); |
3733 | 3899 | ||
3734 | if (CapsModule != null) | 3900 | if (CapsModule != null) |
3735 | { | 3901 | { |
3736 | CapsModule.SetAgentCapsSeeds(agent); | 3902 | CapsModule.SetAgentCapsSeeds(agent); |
@@ -3742,15 +3908,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3742 | // Let the SP know how we got here. This has a lot of interesting | 3908 | // Let the SP know how we got here. This has a lot of interesting |
3743 | // uses down the line. | 3909 | // uses down the line. |
3744 | sp.TeleportFlags = (TPFlags)teleportFlags; | 3910 | sp.TeleportFlags = (TPFlags)teleportFlags; |
3745 | 3911 | ||
3746 | if (sp.IsChildAgent) | 3912 | if (sp.IsChildAgent) |
3747 | { | 3913 | { |
3748 | m_log.DebugFormat( | 3914 | m_log.DebugFormat( |
3749 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3915 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
3750 | agent.AgentID, RegionInfo.RegionName); | 3916 | agent.AgentID, RegionInfo.RegionName); |
3751 | 3917 | ||
3752 | sp.AdjustKnownSeeds(); | 3918 | sp.AdjustKnownSeeds(); |
3753 | 3919 | ||
3754 | if (CapsModule != null) | 3920 | if (CapsModule != null) |
3755 | CapsModule.SetAgentCapsSeeds(agent); | 3921 | CapsModule.SetAgentCapsSeeds(agent); |
3756 | } | 3922 | } |
@@ -3852,6 +4018,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3852 | } | 4018 | } |
3853 | 4019 | ||
3854 | // Honor parcel landing type and position. | 4020 | // Honor parcel landing type and position. |
4021 | /* | ||
4022 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3855 | if (land != null) | 4023 | if (land != null) |
3856 | { | 4024 | { |
3857 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4025 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3859,25 +4027,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
3859 | agent.startpos = land.LandData.UserLocation; | 4027 | agent.startpos = land.LandData.UserLocation; |
3860 | } | 4028 | } |
3861 | } | 4029 | } |
4030 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3862 | } | 4031 | } |
3863 | 4032 | ||
3864 | return true; | 4033 | return true; |
3865 | } | 4034 | } |
3866 | 4035 | ||
3867 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 4036 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3868 | { | 4037 | { |
3869 | bool banned = land.IsBannedFromLand(agent.AgentID); | 4038 | if (posX < 0) |
3870 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 4039 | posX = 0; |
4040 | else if (posX >= 256) | ||
4041 | posX = 255.999f; | ||
4042 | if (posY < 0) | ||
4043 | posY = 0; | ||
4044 | else if (posY >= 256) | ||
4045 | posY = 255.999f; | ||
4046 | |||
4047 | reason = String.Empty; | ||
4048 | if (Permissions.IsGod(agentID)) | ||
4049 | return true; | ||
4050 | |||
4051 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
4052 | if (land == null) | ||
4053 | return false; | ||
4054 | |||
4055 | bool banned = land.IsBannedFromLand(agentID); | ||
4056 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3871 | 4057 | ||
3872 | if (banned || restricted) | 4058 | if (banned || restricted) |
3873 | { | 4059 | { |
3874 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 4060 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3875 | if (nearestParcel != null) | 4061 | if (nearestParcel != null) |
3876 | { | 4062 | { |
3877 | //Move agent to nearest allowed | 4063 | //Move agent to nearest allowed |
3878 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 4064 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3879 | agent.startpos.X = newPosition.X; | 4065 | posX = newPosition.X; |
3880 | agent.startpos.Y = newPosition.Y; | 4066 | posY = newPosition.Y; |
3881 | } | 4067 | } |
3882 | else | 4068 | else |
3883 | { | 4069 | { |
@@ -3939,7 +4125,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3939 | 4125 | ||
3940 | if (!m_strictAccessControl) return true; | 4126 | if (!m_strictAccessControl) return true; |
3941 | if (Permissions.IsGod(agent.AgentID)) return true; | 4127 | if (Permissions.IsGod(agent.AgentID)) return true; |
3942 | 4128 | ||
3943 | if (AuthorizationService != null) | 4129 | if (AuthorizationService != null) |
3944 | { | 4130 | { |
3945 | if (!AuthorizationService.IsAuthorizedForRegion( | 4131 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3954,7 +4140,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3954 | 4140 | ||
3955 | if (RegionInfo.EstateSettings != null) | 4141 | if (RegionInfo.EstateSettings != null) |
3956 | { | 4142 | { |
3957 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4143 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3958 | { | 4144 | { |
3959 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4145 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3960 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4146 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4144,6 +4330,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4144 | 4330 | ||
4145 | // XPTO: if this agent is not allowed here as root, always return false | 4331 | // XPTO: if this agent is not allowed here as root, always return false |
4146 | 4332 | ||
4333 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4334 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4335 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4336 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4337 | { | ||
4338 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4339 | return false; | ||
4340 | } | ||
4341 | |||
4147 | // TODO: This check should probably be in QueryAccess(). | 4342 | // TODO: This check should probably be in QueryAccess(). |
4148 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4343 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4149 | if (nearestParcel == null) | 4344 | if (nearestParcel == null) |
@@ -4208,7 +4403,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4208 | /// <param name='agentID'></param> | 4403 | /// <param name='agentID'></param> |
4209 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4404 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4210 | { | 4405 | { |
4211 | int ntimes = 10; | 4406 | int ntimes = 30; |
4212 | ScenePresence sp = null; | 4407 | ScenePresence sp = null; |
4213 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4408 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4214 | Thread.Sleep(1000); | 4409 | Thread.Sleep(1000); |
@@ -4238,6 +4433,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4238 | return false; | 4433 | return false; |
4239 | } | 4434 | } |
4240 | 4435 | ||
4436 | public bool IncomingCloseAgent(UUID agentID) | ||
4437 | { | ||
4438 | return IncomingCloseAgent(agentID, false); | ||
4439 | } | ||
4440 | |||
4441 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4442 | { | ||
4443 | return IncomingCloseAgent(agentID, true); | ||
4444 | } | ||
4445 | |||
4241 | /// <summary> | 4446 | /// <summary> |
4242 | /// Tell a single agent to disconnect from the region. | 4447 | /// Tell a single agent to disconnect from the region. |
4243 | /// </summary> | 4448 | /// </summary> |
@@ -4253,7 +4458,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4253 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4458 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4254 | if (presence != null) | 4459 | if (presence != null) |
4255 | { | 4460 | { |
4256 | presence.ControllingClient.Close(force); | 4461 | presence.ControllingClient.Close(force, force); |
4257 | return true; | 4462 | return true; |
4258 | } | 4463 | } |
4259 | 4464 | ||
@@ -4886,7 +5091,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4886 | { | 5091 | { |
4887 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5092 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
4888 | { | 5093 | { |
4889 | if (grp.RootPart.Expires <= DateTime.Now) | 5094 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
4890 | DeleteSceneObject(grp, false); | 5095 | DeleteSceneObject(grp, false); |
4891 | } | 5096 | } |
4892 | } | 5097 | } |
@@ -4900,35 +5105,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4900 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5105 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4901 | } | 5106 | } |
4902 | 5107 | ||
4903 | public int GetHealth() | 5108 | public int GetHealth(out int flags, out string message) |
4904 | { | 5109 | { |
4905 | // Returns: | 5110 | // Returns: |
4906 | // 1 = sim is up and accepting http requests. The heartbeat has | 5111 | // 1 = sim is up and accepting http requests. The heartbeat has |
4907 | // stopped and the sim is probably locked up, but a remote | 5112 | // stopped and the sim is probably locked up, but a remote |
4908 | // admin restart may succeed | 5113 | // admin restart may succeed |
4909 | // | 5114 | // |
4910 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5115 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4911 | // usable for people within and logins _may_ work | 5116 | // usable for people within |
5117 | // | ||
5118 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5119 | // unstable and will not accept new logins | ||
5120 | // | ||
5121 | // 4 = Sim is up and both packet threads are running. Sim is | ||
5122 | // likely usable | ||
4912 | // | 5123 | // |
4913 | // 3 = We have seen a new user enter within the past 4 minutes | 5124 | // 5 = We have seen a new user enter within the past 4 minutes |
4914 | // which can be seen as positive confirmation of sim health | 5125 | // which can be seen as positive confirmation of sim health |
4915 | // | 5126 | // |
5127 | |||
5128 | flags = 0; | ||
5129 | message = String.Empty; | ||
5130 | |||
5131 | CheckHeartbeat(); | ||
5132 | |||
5133 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5134 | { | ||
5135 | // We're still starting | ||
5136 | // 0 means "in startup", it can't happen another way, since | ||
5137 | // to get here, we must be able to accept http connections | ||
5138 | return 0; | ||
5139 | } | ||
5140 | |||
4916 | int health=1; // Start at 1, means we're up | 5141 | int health=1; // Start at 1, means we're up |
4917 | 5142 | ||
4918 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5143 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4919 | health += 1; | 5144 | { |
5145 | health+=1; | ||
5146 | flags |= 1; | ||
5147 | } | ||
5148 | |||
5149 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5150 | { | ||
5151 | health+=1; | ||
5152 | flags |= 2; | ||
5153 | } | ||
5154 | |||
5155 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5156 | { | ||
5157 | health+=1; | ||
5158 | flags |= 4; | ||
5159 | } | ||
4920 | else | 5160 | else |
5161 | { | ||
5162 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5163 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5164 | proc.EnableRaisingEvents=false; | ||
5165 | proc.StartInfo.FileName = "/bin/kill"; | ||
5166 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5167 | proc.Start(); | ||
5168 | proc.WaitForExit(); | ||
5169 | Thread.Sleep(1000); | ||
5170 | Environment.Exit(1); | ||
5171 | } | ||
5172 | |||
5173 | if (flags != 7) | ||
4921 | return health; | 5174 | return health; |
4922 | 5175 | ||
4923 | // A login in the last 4 mins? We can't be doing too badly | 5176 | // A login in the last 4 mins? We can't be doing too badly |
4924 | // | 5177 | // |
4925 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5178 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4926 | health++; | 5179 | health++; |
4927 | else | 5180 | else |
4928 | return health; | 5181 | return health; |
4929 | 5182 | ||
4930 | // CheckHeartbeat(); | ||
4931 | |||
4932 | return health; | 5183 | return health; |
4933 | } | 5184 | } |
4934 | 5185 | ||
@@ -5016,7 +5267,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5016 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5267 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5017 | if (wasUsingPhysics) | 5268 | if (wasUsingPhysics) |
5018 | { | 5269 | { |
5019 | 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 | 5270 | 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 |
5020 | } | 5271 | } |
5021 | } | 5272 | } |
5022 | 5273 | ||
@@ -5115,14 +5366,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5115 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5366 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5116 | } | 5367 | } |
5117 | 5368 | ||
5118 | // private void CheckHeartbeat() | 5369 | private void CheckHeartbeat() |
5119 | // { | 5370 | { |
5120 | // if (m_firstHeartbeat) | 5371 | if (m_firstHeartbeat) |
5121 | // return; | 5372 | return; |
5122 | // | 5373 | |
5123 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5374 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5124 | // StartTimer(); | 5375 | Start(); |
5125 | // } | 5376 | } |
5126 | 5377 | ||
5127 | public override ISceneObject DeserializeObject(string representation) | 5378 | public override ISceneObject DeserializeObject(string representation) |
5128 | { | 5379 | { |
@@ -5134,9 +5385,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5134 | get { return m_allowScriptCrossings; } | 5385 | get { return m_allowScriptCrossings; } |
5135 | } | 5386 | } |
5136 | 5387 | ||
5137 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5388 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5138 | { | 5389 | { |
5139 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5390 | return GetNearestAllowedPosition(avatar, null); |
5391 | } | ||
5392 | |||
5393 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
5394 | { | ||
5395 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
5140 | 5396 | ||
5141 | if (nearestParcel != null) | 5397 | if (nearestParcel != null) |
5142 | { | 5398 | { |
@@ -5145,10 +5401,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5145 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5401 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5146 | if (nearestPoint != null) | 5402 | if (nearestPoint != null) |
5147 | { | 5403 | { |
5148 | // m_log.DebugFormat( | 5404 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
5149 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
5150 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
5151 | |||
5152 | return nearestPoint.Value; | 5405 | return nearestPoint.Value; |
5153 | } | 5406 | } |
5154 | 5407 | ||
@@ -5158,17 +5411,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
5158 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5411 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5159 | if (nearestPoint != null) | 5412 | if (nearestPoint != null) |
5160 | { | 5413 | { |
5161 | // m_log.DebugFormat( | 5414 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
5162 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
5163 | |||
5164 | return nearestPoint.Value; | 5415 | return nearestPoint.Value; |
5165 | } | 5416 | } |
5166 | 5417 | ||
5167 | //Ultimate backup if we have no idea where they are | 5418 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
5168 | // m_log.DebugFormat( | 5419 | if (dest != excludeParcel) |
5169 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5420 | { |
5421 | // Ultimate backup if we have no idea where they are and | ||
5422 | // the last allowed position was in another parcel | ||
5423 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5424 | return avatar.lastKnownAllowedPosition; | ||
5425 | } | ||
5170 | 5426 | ||
5171 | return avatar.lastKnownAllowedPosition; | 5427 | // else fall through to region edge |
5172 | } | 5428 | } |
5173 | 5429 | ||
5174 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5430 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -5202,13 +5458,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5202 | 5458 | ||
5203 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5459 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
5204 | { | 5460 | { |
5461 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5462 | } | ||
5463 | |||
5464 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5465 | { | ||
5205 | List<ILandObject> all = AllParcels(); | 5466 | List<ILandObject> all = AllParcels(); |
5206 | float minParcelDistance = float.MaxValue; | 5467 | float minParcelDistance = float.MaxValue; |
5207 | ILandObject nearestParcel = null; | 5468 | ILandObject nearestParcel = null; |
5208 | 5469 | ||
5209 | foreach (var parcel in all) | 5470 | foreach (var parcel in all) |
5210 | { | 5471 | { |
5211 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5472 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
5212 | { | 5473 | { |
5213 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5474 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
5214 | if (parcelDistance < minParcelDistance) | 5475 | if (parcelDistance < minParcelDistance) |
@@ -5424,7 +5685,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5424 | mapModule.GenerateMaptile(); | 5685 | mapModule.GenerateMaptile(); |
5425 | } | 5686 | } |
5426 | 5687 | ||
5427 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5688 | // public void CleanDroppedAttachments() |
5689 | // { | ||
5690 | // List<SceneObjectGroup> objectsToDelete = | ||
5691 | // new List<SceneObjectGroup>(); | ||
5692 | // | ||
5693 | // lock (m_cleaningAttachments) | ||
5694 | // { | ||
5695 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5696 | // { | ||
5697 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5698 | // { | ||
5699 | // UUID agentID = grp.OwnerID; | ||
5700 | // if (agentID == UUID.Zero) | ||
5701 | // { | ||
5702 | // objectsToDelete.Add(grp); | ||
5703 | // return; | ||
5704 | // } | ||
5705 | // | ||
5706 | // ScenePresence sp = GetScenePresence(agentID); | ||
5707 | // if (sp == null) | ||
5708 | // { | ||
5709 | // objectsToDelete.Add(grp); | ||
5710 | // return; | ||
5711 | // } | ||
5712 | // } | ||
5713 | // }); | ||
5714 | // } | ||
5715 | // | ||
5716 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5717 | // { | ||
5718 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5719 | // DeleteSceneObject(grp, true); | ||
5720 | // } | ||
5721 | // } | ||
5722 | |||
5723 | public void ThreadAlive(int threadCode) | ||
5724 | { | ||
5725 | switch(threadCode) | ||
5726 | { | ||
5727 | case 1: // Incoming | ||
5728 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5729 | break; | ||
5730 | case 2: // Incoming | ||
5731 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5732 | break; | ||
5733 | } | ||
5734 | } | ||
5735 | |||
5736 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5428 | { | 5737 | { |
5429 | RegenerateMaptile(); | 5738 | RegenerateMaptile(); |
5430 | 5739 | ||
@@ -5452,6 +5761,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5452 | /// <returns></returns> | 5761 | /// <returns></returns> |
5453 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5762 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5454 | { | 5763 | { |
5764 | reason = "You are banned from the region"; | ||
5765 | |||
5455 | if (EntityTransferModule.IsInTransit(agentID)) | 5766 | if (EntityTransferModule.IsInTransit(agentID)) |
5456 | { | 5767 | { |
5457 | reason = "Agent is still in transit from this region"; | 5768 | reason = "Agent is still in transit from this region"; |
@@ -5463,6 +5774,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5463 | return false; | 5774 | return false; |
5464 | } | 5775 | } |
5465 | 5776 | ||
5777 | if (Permissions.IsGod(agentID)) | ||
5778 | { | ||
5779 | reason = String.Empty; | ||
5780 | return true; | ||
5781 | } | ||
5782 | |||
5466 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5783 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5467 | // However, the long term fix is to make sure root agent count is always accurate. | 5784 | // However, the long term fix is to make sure root agent count is always accurate. |
5468 | m_sceneGraph.RecalculateStats(); | 5785 | m_sceneGraph.RecalculateStats(); |
@@ -5483,6 +5800,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5483 | } | 5800 | } |
5484 | } | 5801 | } |
5485 | 5802 | ||
5803 | ScenePresence presence = GetScenePresence(agentID); | ||
5804 | IClientAPI client = null; | ||
5805 | AgentCircuitData aCircuit = null; | ||
5806 | |||
5807 | if (presence != null) | ||
5808 | { | ||
5809 | client = presence.ControllingClient; | ||
5810 | if (client != null) | ||
5811 | aCircuit = client.RequestClientInfo(); | ||
5812 | } | ||
5813 | |||
5814 | // We may be called before there is a presence or a client. | ||
5815 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5816 | if (client == null) | ||
5817 | { | ||
5818 | aCircuit = new AgentCircuitData(); | ||
5819 | aCircuit.AgentID = agentID; | ||
5820 | aCircuit.firstname = String.Empty; | ||
5821 | aCircuit.lastname = String.Empty; | ||
5822 | } | ||
5823 | |||
5824 | try | ||
5825 | { | ||
5826 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5827 | { | ||
5828 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5829 | return false; | ||
5830 | } | ||
5831 | } | ||
5832 | catch (Exception e) | ||
5833 | { | ||
5834 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5835 | return false; | ||
5836 | } | ||
5837 | |||
5486 | if (position == Vector3.Zero) // Teleport | 5838 | if (position == Vector3.Zero) // Teleport |
5487 | { | 5839 | { |
5488 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5840 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5511,13 +5863,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5511 | } | 5863 | } |
5512 | } | 5864 | } |
5513 | } | 5865 | } |
5866 | |||
5867 | float posX = 128.0f; | ||
5868 | float posY = 128.0f; | ||
5869 | |||
5870 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5871 | { | ||
5872 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5873 | return false; | ||
5874 | } | ||
5875 | } | ||
5876 | else // Walking | ||
5877 | { | ||
5878 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5879 | if (land == null) | ||
5880 | return false; | ||
5881 | |||
5882 | bool banned = land.IsBannedFromLand(agentID); | ||
5883 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5884 | |||
5885 | if (banned || restricted) | ||
5886 | return false; | ||
5514 | } | 5887 | } |
5515 | 5888 | ||
5516 | reason = String.Empty; | 5889 | reason = String.Empty; |
5517 | return true; | 5890 | return true; |
5518 | } | 5891 | } |
5519 | 5892 | ||
5520 | /// <summary> | 5893 | public void StartTimerWatchdog() |
5894 | { | ||
5895 | m_timerWatchdog.Interval = 1000; | ||
5896 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5897 | m_timerWatchdog.AutoReset = true; | ||
5898 | m_timerWatchdog.Start(); | ||
5899 | } | ||
5900 | |||
5901 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5902 | { | ||
5903 | CheckHeartbeat(); | ||
5904 | } | ||
5905 | |||
5521 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5906 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5522 | /// autopilot that moves an avatar to a sit target!. | 5907 | /// autopilot that moves an avatar to a sit target!. |
5523 | /// </summary> | 5908 | /// </summary> |
@@ -5596,6 +5981,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5596 | return m_SpawnPoint - 1; | 5981 | return m_SpawnPoint - 1; |
5597 | } | 5982 | } |
5598 | 5983 | ||
5984 | private void HandleGcCollect(string module, string[] args) | ||
5985 | { | ||
5986 | GC.Collect(); | ||
5987 | } | ||
5988 | |||
5599 | /// <summary> | 5989 | /// <summary> |
5600 | /// Wrappers to get physics modules retrieve assets. | 5990 | /// Wrappers to get physics modules retrieve assets. |
5601 | /// </summary> | 5991 | /// </summary> |