diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 830 |
1 files changed, 483 insertions, 347 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 48aca98..f437bc8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -77,7 +77,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
77 | public bool DebugUpdates { get; private set; } | 77 | public bool DebugUpdates { get; private set; } |
78 | 78 | ||
79 | public SynchronizeSceneHandler SynchronizeScene; | 79 | public SynchronizeSceneHandler SynchronizeScene; |
80 | public SimStatsReporter StatsReporter; | 80 | |
81 | /// <summary> | ||
82 | /// Statistical information for this scene. | ||
83 | /// </summary> | ||
84 | public SimStatsReporter StatsReporter { get; private set; } | ||
85 | |||
81 | public List<Border> NorthBorders = new List<Border>(); | 86 | public List<Border> NorthBorders = new List<Border>(); |
82 | public List<Border> EastBorders = new List<Border>(); | 87 | public List<Border> EastBorders = new List<Border>(); |
83 | public List<Border> SouthBorders = new List<Border>(); | 88 | public List<Border> SouthBorders = new List<Border>(); |
@@ -103,6 +108,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | public bool m_trustBinaries; | 108 | public bool m_trustBinaries; |
104 | public bool m_allowScriptCrossings; | 109 | public bool m_allowScriptCrossings; |
105 | public bool m_useFlySlow; | 110 | public bool m_useFlySlow; |
111 | public bool m_useTrashOnDelete = true; | ||
106 | 112 | ||
107 | /// <summary> | 113 | /// <summary> |
108 | /// Temporarily setting to trigger appearance resends at 60 second intervals. | 114 | /// Temporarily setting to trigger appearance resends at 60 second intervals. |
@@ -114,6 +120,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
114 | { | 120 | { |
115 | get { return m_defaultDrawDistance; } | 121 | get { return m_defaultDrawDistance; } |
116 | } | 122 | } |
123 | |||
124 | private List<string> m_AllowedViewers = new List<string>(); | ||
125 | private List<string> m_BannedViewers = new List<string>(); | ||
117 | 126 | ||
118 | // TODO: need to figure out how allow client agents but deny | 127 | // TODO: need to figure out how allow client agents but deny |
119 | // root agents when ACL denies access to root agent | 128 | // root agents when ACL denies access to root agent |
@@ -163,7 +172,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
163 | protected IConfigSource m_config; | 172 | protected IConfigSource m_config; |
164 | protected IRegionSerialiserModule m_serialiser; | 173 | protected IRegionSerialiserModule m_serialiser; |
165 | protected IDialogModule m_dialogModule; | 174 | protected IDialogModule m_dialogModule; |
166 | protected IEntityTransferModule m_teleportModule; | ||
167 | protected ICapabilitiesModule m_capsModule; | 175 | protected ICapabilitiesModule m_capsModule; |
168 | protected IGroupsModule m_groupsModule; | 176 | protected IGroupsModule m_groupsModule; |
169 | 177 | ||
@@ -217,6 +225,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
217 | private int backupMS; | 225 | private int backupMS; |
218 | private int terrainMS; | 226 | private int terrainMS; |
219 | private int landMS; | 227 | private int landMS; |
228 | private int spareMS; | ||
220 | 229 | ||
221 | /// <summary> | 230 | /// <summary> |
222 | /// Tick at which the last frame was processed. | 231 | /// Tick at which the last frame was processed. |
@@ -458,6 +467,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | { | 467 | { |
459 | if (m_simulationService == null) | 468 | if (m_simulationService == null) |
460 | m_simulationService = RequestModuleInterface<ISimulationService>(); | 469 | m_simulationService = RequestModuleInterface<ISimulationService>(); |
470 | |||
461 | return m_simulationService; | 471 | return m_simulationService; |
462 | } | 472 | } |
463 | } | 473 | } |
@@ -513,6 +523,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
513 | } | 523 | } |
514 | 524 | ||
515 | public IAttachmentsModule AttachmentsModule { get; set; } | 525 | public IAttachmentsModule AttachmentsModule { get; set; } |
526 | public IEntityTransferModule EntityTransferModule { get; private set; } | ||
527 | public IAgentAssetTransactions AgentTransactionsModule { get; private set; } | ||
528 | public IUserManagement UserManagementModule { get; private set; } | ||
516 | 529 | ||
517 | public IAvatarFactoryModule AvatarFactory | 530 | public IAvatarFactoryModule AvatarFactory |
518 | { | 531 | { |
@@ -589,6 +602,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
589 | get { return m_sceneGraph.Entities; } | 602 | get { return m_sceneGraph.Entities; } |
590 | } | 603 | } |
591 | 604 | ||
605 | |||
606 | // used in sequence see: SpawnPoint() | ||
607 | private int m_SpawnPoint; | ||
608 | // can be closest/random/sequence | ||
609 | public string SpawnPointRouting | ||
610 | { | ||
611 | get; private set; | ||
612 | } | ||
613 | // allow landmarks to pass | ||
614 | public bool TelehubAllowLandmarks | ||
615 | { | ||
616 | get; private set; | ||
617 | } | ||
618 | |||
592 | #endregion Properties | 619 | #endregion Properties |
593 | 620 | ||
594 | #region Constructors | 621 | #region Constructors |
@@ -606,14 +633,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
606 | 633 | ||
607 | Random random = new Random(); | 634 | Random random = new Random(); |
608 | 635 | ||
609 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); | 636 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4); |
610 | m_moduleLoader = moduleLoader; | 637 | m_moduleLoader = moduleLoader; |
611 | m_authenticateHandler = authen; | 638 | m_authenticateHandler = authen; |
612 | m_sceneGridService = sceneGridService; | 639 | m_sceneGridService = sceneGridService; |
613 | m_SimulationDataService = simDataService; | 640 | m_SimulationDataService = simDataService; |
614 | m_EstateDataService = estateDataService; | 641 | m_EstateDataService = estateDataService; |
615 | m_regionHandle = m_regInfo.RegionHandle; | 642 | m_regionHandle = m_regInfo.RegionHandle; |
616 | m_regionName = m_regInfo.RegionName; | ||
617 | m_lastIncoming = 0; | 643 | m_lastIncoming = 0; |
618 | m_lastOutgoing = 0; | 644 | m_lastOutgoing = 0; |
619 | 645 | ||
@@ -630,7 +656,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
630 | // resave. | 656 | // resave. |
631 | // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new | 657 | // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new |
632 | // region is set up and avoid these gyrations. | 658 | // region is set up and avoid these gyrations. |
633 | RegionSettings rs = simDataService.LoadRegionSettings(m_regInfo.RegionID); | 659 | RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID); |
634 | bool updatedTerrainTextures = false; | 660 | bool updatedTerrainTextures = false; |
635 | if (rs.TerrainTexture1 == UUID.Zero) | 661 | if (rs.TerrainTexture1 == UUID.Zero) |
636 | { | 662 | { |
@@ -659,10 +685,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
659 | if (updatedTerrainTextures) | 685 | if (updatedTerrainTextures) |
660 | rs.Save(); | 686 | rs.Save(); |
661 | 687 | ||
662 | m_regInfo.RegionSettings = rs; | 688 | RegionInfo.RegionSettings = rs; |
663 | 689 | ||
664 | if (estateDataService != null) | 690 | if (estateDataService != null) |
665 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); | 691 | RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false); |
666 | 692 | ||
667 | #endregion Region Settings | 693 | #endregion Region Settings |
668 | 694 | ||
@@ -726,6 +752,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
726 | m_maxPhys = RegionInfo.PhysPrimMax; | 752 | m_maxPhys = RegionInfo.PhysPrimMax; |
727 | } | 753 | } |
728 | 754 | ||
755 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
756 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
757 | |||
729 | // Here, if clamping is requested in either global or | 758 | // Here, if clamping is requested in either global or |
730 | // local config, it will be used | 759 | // local config, it will be used |
731 | // | 760 | // |
@@ -735,6 +764,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
735 | m_clampPrimSize = true; | 764 | m_clampPrimSize = true; |
736 | } | 765 | } |
737 | 766 | ||
767 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); | ||
738 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 768 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
739 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 769 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
740 | m_dontPersistBefore = | 770 | m_dontPersistBefore = |
@@ -781,6 +811,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
781 | } | 811 | } |
782 | } | 812 | } |
783 | 813 | ||
814 | string grant = startupConfig.GetString("AllowedClients", String.Empty); | ||
815 | if (grant.Length > 0) | ||
816 | { | ||
817 | foreach (string viewer in grant.Split(',')) | ||
818 | { | ||
819 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | ||
820 | } | ||
821 | } | ||
822 | |||
823 | grant = startupConfig.GetString("BannedClients", String.Empty); | ||
824 | if (grant.Length > 0) | ||
825 | { | ||
826 | foreach (string viewer in grant.Split(',')) | ||
827 | { | ||
828 | m_BannedViewers.Add(viewer.Trim().ToLower()); | ||
829 | } | ||
830 | } | ||
831 | |||
784 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 832 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
785 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 833 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); |
786 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 834 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); |
@@ -835,13 +883,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
835 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | 883 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); |
836 | } | 884 | } |
837 | 885 | ||
838 | /// <summary> | 886 | public Scene(RegionInfo regInfo) : base(regInfo) |
839 | /// Mock constructor for scene group persistency unit tests. | ||
840 | /// SceneObjectGroup RegionId property is delegated to Scene. | ||
841 | /// </summary> | ||
842 | /// <param name="regInfo"></param> | ||
843 | public Scene(RegionInfo regInfo) | ||
844 | { | 887 | { |
888 | PhysicalPrims = true; | ||
889 | CollidablePrims = true; | ||
890 | |||
845 | BordersLocked = true; | 891 | BordersLocked = true; |
846 | Border northBorder = new Border(); | 892 | Border northBorder = new Border(); |
847 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- | 893 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- |
@@ -864,12 +910,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
864 | WestBorders.Add(westBorder); | 910 | WestBorders.Add(westBorder); |
865 | BordersLocked = false; | 911 | BordersLocked = false; |
866 | 912 | ||
867 | m_regInfo = regInfo; | ||
868 | m_eventManager = new EventManager(); | 913 | m_eventManager = new EventManager(); |
869 | 914 | ||
870 | m_permissions = new ScenePermissions(this); | 915 | m_permissions = new ScenePermissions(this); |
871 | |||
872 | // m_lastUpdate = Util.EnvironmentTickCount(); | ||
873 | } | 916 | } |
874 | 917 | ||
875 | #endregion | 918 | #endregion |
@@ -938,8 +981,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
938 | List<ulong> old = new List<ulong>(); | 981 | List<ulong> old = new List<ulong>(); |
939 | old.Add(otherRegion.RegionHandle); | 982 | old.Add(otherRegion.RegionHandle); |
940 | agent.DropOldNeighbours(old); | 983 | agent.DropOldNeighbours(old); |
941 | if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) | 984 | if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc) |
942 | m_teleportModule.EnableChildAgent(agent, otherRegion); | 985 | EntityTransferModule.EnableChildAgent(agent, otherRegion); |
943 | }); | 986 | }); |
944 | } | 987 | } |
945 | catch (NullReferenceException) | 988 | catch (NullReferenceException) |
@@ -952,7 +995,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
952 | else | 995 | else |
953 | { | 996 | { |
954 | m_log.InfoFormat( | 997 | m_log.InfoFormat( |
955 | "[INTERGRID]: Got notice about far away Region: {0} at ({1}, {2})", | 998 | "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})", |
956 | otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); | 999 | otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); |
957 | } | 1000 | } |
958 | } | 1001 | } |
@@ -1046,13 +1089,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1046 | } | 1089 | } |
1047 | } | 1090 | } |
1048 | 1091 | ||
1092 | m_log.Error("[REGION]: Closing"); | ||
1093 | Close(); | ||
1094 | |||
1049 | if (PhysicsScene != null) | 1095 | if (PhysicsScene != null) |
1050 | { | 1096 | { |
1051 | PhysicsScene.Dispose(); | 1097 | PhysicsScene.Dispose(); |
1052 | } | 1098 | } |
1053 | |||
1054 | m_log.Error("[REGION]: Closing"); | ||
1055 | Close(); | ||
1056 | 1099 | ||
1057 | m_log.Error("[REGION]: Firing Region Restart Message"); | 1100 | m_log.Error("[REGION]: Firing Region Restart Message"); |
1058 | 1101 | ||
@@ -1076,8 +1119,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1076 | { | 1119 | { |
1077 | ForEachRootScenePresence(delegate(ScenePresence agent) | 1120 | ForEachRootScenePresence(delegate(ScenePresence agent) |
1078 | { | 1121 | { |
1079 | if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) | 1122 | if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc) |
1080 | m_teleportModule.EnableChildAgent(agent, r); | 1123 | EntityTransferModule.EnableChildAgent(agent, r); |
1081 | }); | 1124 | }); |
1082 | } | 1125 | } |
1083 | catch (NullReferenceException) | 1126 | catch (NullReferenceException) |
@@ -1210,8 +1253,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1210 | 1253 | ||
1211 | m_sceneGraph.Close(); | 1254 | m_sceneGraph.Close(); |
1212 | 1255 | ||
1213 | if (!GridService.DeregisterRegion(m_regInfo.RegionID)) | 1256 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) |
1214 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName); | 1257 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); |
1215 | 1258 | ||
1216 | // call the base class Close method. | 1259 | // call the base class Close method. |
1217 | base.Close(); | 1260 | base.Close(); |
@@ -1267,8 +1310,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1267 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); | 1310 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); |
1268 | m_dialogModule = RequestModuleInterface<IDialogModule>(); | 1311 | m_dialogModule = RequestModuleInterface<IDialogModule>(); |
1269 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); | 1312 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); |
1270 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); | 1313 | EntityTransferModule = RequestModuleInterface<IEntityTransferModule>(); |
1271 | m_groupsModule = RequestModuleInterface<IGroupsModule>(); | 1314 | m_groupsModule = RequestModuleInterface<IGroupsModule>(); |
1315 | AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>(); | ||
1316 | UserManagementModule = RequestModuleInterface<IUserManagement>(); | ||
1272 | } | 1317 | } |
1273 | 1318 | ||
1274 | #endregion | 1319 | #endregion |
@@ -1389,37 +1434,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1389 | endFrame = Frame + frames; | 1434 | endFrame = Frame + frames; |
1390 | 1435 | ||
1391 | float physicsFPS = 0f; | 1436 | float physicsFPS = 0f; |
1392 | int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; | 1437 | int previousFrameTick, tmpMS; |
1393 | int previousFrameTick; | 1438 | int maintc = Util.EnvironmentTickCount(); |
1394 | int maintc; | ||
1395 | int sleepMS; | ||
1396 | int framestart; | ||
1397 | 1439 | ||
1398 | while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) | 1440 | while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) |
1399 | { | 1441 | { |
1400 | framestart = Util.EnvironmentTickCount(); | ||
1401 | ++Frame; | 1442 | ++Frame; |
1402 | 1443 | ||
1403 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1444 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1404 | 1445 | ||
1405 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | 1446 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; |
1406 | 1447 | ||
1407 | try | 1448 | try |
1408 | { | 1449 | { |
1409 | tmpPhysicsMS2 = Util.EnvironmentTickCount(); | 1450 | // Apply taints in terrain module to terrain in physics scene |
1451 | if (Frame % m_update_terrain == 0) | ||
1452 | { | ||
1453 | tmpMS = Util.EnvironmentTickCount(); | ||
1454 | UpdateTerrain(); | ||
1455 | terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); | ||
1456 | } | ||
1457 | |||
1458 | tmpMS = Util.EnvironmentTickCount(); | ||
1410 | if ((Frame % m_update_physics == 0) && m_physics_enabled) | 1459 | if ((Frame % m_update_physics == 0) && m_physics_enabled) |
1411 | m_sceneGraph.UpdatePreparePhysics(); | 1460 | m_sceneGraph.UpdatePreparePhysics(); |
1412 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); | 1461 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); |
1413 | 1462 | ||
1414 | // Apply any pending avatar force input to the avatar's velocity | 1463 | // Apply any pending avatar force input to the avatar's velocity |
1415 | tmpAgentMS = Util.EnvironmentTickCount(); | 1464 | tmpMS = Util.EnvironmentTickCount(); |
1416 | if (Frame % m_update_entitymovement == 0) | 1465 | if (Frame % m_update_entitymovement == 0) |
1417 | m_sceneGraph.UpdateScenePresenceMovement(); | 1466 | m_sceneGraph.UpdateScenePresenceMovement(); |
1418 | agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); | 1467 | agentMS = Util.EnvironmentTickCountSubtract(tmpMS); |
1419 | 1468 | ||
1420 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their | 1469 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their |
1421 | // velocity | 1470 | // velocity |
1422 | tmpPhysicsMS = Util.EnvironmentTickCount(); | 1471 | tmpMS = Util.EnvironmentTickCount(); |
1423 | if (Frame % m_update_physics == 0) | 1472 | if (Frame % m_update_physics == 0) |
1424 | { | 1473 | { |
1425 | if (m_physics_enabled) | 1474 | if (m_physics_enabled) |
@@ -1428,9 +1477,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1428 | if (SynchronizeScene != null) | 1477 | if (SynchronizeScene != null) |
1429 | SynchronizeScene(this); | 1478 | SynchronizeScene(this); |
1430 | } | 1479 | } |
1431 | physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); | 1480 | physicsMS = Util.EnvironmentTickCountSubtract(tmpMS); |
1432 | 1481 | ||
1433 | tmpAgentMS = Util.EnvironmentTickCount(); | 1482 | tmpMS = Util.EnvironmentTickCount(); |
1434 | 1483 | ||
1435 | // Check if any objects have reached their targets | 1484 | // Check if any objects have reached their targets |
1436 | CheckAtTargets(); | 1485 | CheckAtTargets(); |
@@ -1445,36 +1494,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1445 | if (Frame % m_update_presences == 0) | 1494 | if (Frame % m_update_presences == 0) |
1446 | m_sceneGraph.UpdatePresences(); | 1495 | m_sceneGraph.UpdatePresences(); |
1447 | 1496 | ||
1448 | agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); | 1497 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1449 | 1498 | ||
1450 | // Delete temp-on-rez stuff | 1499 | // Delete temp-on-rez stuff |
1451 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1500 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
1452 | { | 1501 | { |
1453 | tmpTempOnRezMS = Util.EnvironmentTickCount(); | 1502 | tmpMS = Util.EnvironmentTickCount(); |
1454 | m_cleaningTemps = true; | 1503 | m_cleaningTemps = true; |
1455 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); | 1504 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); |
1456 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); | 1505 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS); |
1457 | } | 1506 | } |
1458 | 1507 | ||
1459 | if (Frame % m_update_events == 0) | 1508 | if (Frame % m_update_events == 0) |
1460 | { | 1509 | { |
1461 | evMS = Util.EnvironmentTickCount(); | 1510 | tmpMS = Util.EnvironmentTickCount(); |
1462 | UpdateEvents(); | 1511 | UpdateEvents(); |
1463 | eventMS = Util.EnvironmentTickCountSubtract(evMS); | 1512 | eventMS = Util.EnvironmentTickCountSubtract(tmpMS); |
1464 | } | 1513 | } |
1465 | 1514 | ||
1466 | if (Frame % m_update_backup == 0) | 1515 | if (Frame % m_update_backup == 0) |
1467 | { | 1516 | { |
1468 | backMS = Util.EnvironmentTickCount(); | 1517 | tmpMS = Util.EnvironmentTickCount(); |
1469 | UpdateStorageBackup(); | 1518 | UpdateStorageBackup(); |
1470 | backupMS = Util.EnvironmentTickCountSubtract(backMS); | 1519 | backupMS = Util.EnvironmentTickCountSubtract(tmpMS); |
1471 | } | ||
1472 | |||
1473 | if (Frame % m_update_terrain == 0) | ||
1474 | { | ||
1475 | terMS = Util.EnvironmentTickCount(); | ||
1476 | UpdateTerrain(); | ||
1477 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | ||
1478 | } | 1520 | } |
1479 | 1521 | ||
1480 | //if (Frame % m_update_land == 0) | 1522 | //if (Frame % m_update_land == 0) |
@@ -1483,29 +1525,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1483 | // UpdateLand(); | 1525 | // UpdateLand(); |
1484 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1526 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1485 | //} | 1527 | //} |
1486 | |||
1487 | // frameMS = Util.EnvironmentTickCountSubtract(maintc); | ||
1488 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1489 | |||
1490 | // if (Frame%m_update_avatars == 0) | ||
1491 | // UpdateInWorldTime(); | ||
1492 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1493 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1494 | StatsReporter.AddFPS(1); | ||
1495 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | ||
1496 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | ||
1497 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | ||
1498 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1499 | |||
1500 | // frameMS currently records work frame times, not total frame times (work + any required sleep to | ||
1501 | // reach min frame time. | ||
1502 | // StatsReporter.addFrameMS(frameMS); | ||
1503 | |||
1504 | StatsReporter.addAgentMS(agentMS); | ||
1505 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1506 | StatsReporter.addOtherMS(otherMS); | ||
1507 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1508 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1509 | 1528 | ||
1510 | if (LoginsDisabled && Frame == 20) | 1529 | if (LoginsDisabled && Frame == 20) |
1511 | { | 1530 | { |
@@ -1526,11 +1545,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1526 | LoginLock = false; | 1545 | LoginLock = false; |
1527 | EventManager.TriggerLoginsEnabled(RegionInfo.RegionName); | 1546 | EventManager.TriggerLoginsEnabled(RegionInfo.RegionName); |
1528 | } | 1547 | } |
1529 | m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); | ||
1530 | 1548 | ||
1531 | // For RegionReady lockouts | 1549 | // For RegionReady lockouts |
1532 | if(LoginLock == false) | 1550 | if (!LoginLock) |
1533 | { | 1551 | { |
1552 | m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); | ||
1534 | LoginsDisabled = false; | 1553 | LoginsDisabled = false; |
1535 | } | 1554 | } |
1536 | 1555 | ||
@@ -1556,23 +1575,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
1556 | 1575 | ||
1557 | previousFrameTick = m_lastFrameTick; | 1576 | previousFrameTick = m_lastFrameTick; |
1558 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1577 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1559 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); | 1578 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); |
1560 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1579 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1561 | 1580 | ||
1562 | m_firstHeartbeat = false; | 1581 | m_firstHeartbeat = false; |
1563 | 1582 | ||
1583 | if (tmpMS > 0) | ||
1584 | { | ||
1585 | Thread.Sleep(tmpMS); | ||
1586 | spareMS += tmpMS; | ||
1587 | } | ||
1588 | |||
1589 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | ||
1590 | maintc = Util.EnvironmentTickCount(); | ||
1564 | 1591 | ||
1565 | sleepMS = Util.EnvironmentTickCount(); | 1592 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
1566 | 1593 | ||
1567 | if (maintc > 0) | 1594 | // if (Frame%m_update_avatars == 0) |
1568 | Thread.Sleep(maintc); | 1595 | // UpdateInWorldTime(); |
1596 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1597 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1598 | StatsReporter.AddFPS(1); | ||
1569 | 1599 | ||
1570 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); | ||
1571 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1572 | StatsReporter.addSleepMS(sleepMS); | ||
1573 | StatsReporter.addFrameMS(frameMS); | 1600 | StatsReporter.addFrameMS(frameMS); |
1574 | 1601 | StatsReporter.addAgentMS(agentMS); | |
1575 | // Optionally warn if a frame takes double the amount of time that it should. | 1602 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
1603 | StatsReporter.addOtherMS(otherMS); | ||
1604 | StatsReporter.AddSpareMS(spareMS); | ||
1605 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1606 | |||
1607 | // Optionally warn if a frame takes double the amount of time that it should. | ||
1576 | if (DebugUpdates | 1608 | if (DebugUpdates |
1577 | && Util.EnvironmentTickCountSubtract( | 1609 | && Util.EnvironmentTickCountSubtract( |
1578 | m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) | 1610 | m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) |
@@ -1759,14 +1791,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1759 | 1791 | ||
1760 | public void StoreWindlightProfile(RegionLightShareData wl) | 1792 | public void StoreWindlightProfile(RegionLightShareData wl) |
1761 | { | 1793 | { |
1762 | m_regInfo.WindlightSettings = wl; | 1794 | RegionInfo.WindlightSettings = wl; |
1763 | SimulationDataService.StoreRegionWindlightSettings(wl); | 1795 | SimulationDataService.StoreRegionWindlightSettings(wl); |
1764 | m_eventManager.TriggerOnSaveNewWindlightProfile(); | 1796 | m_eventManager.TriggerOnSaveNewWindlightProfile(); |
1765 | } | 1797 | } |
1766 | 1798 | ||
1767 | public void LoadWindlightProfile() | 1799 | public void LoadWindlightProfile() |
1768 | { | 1800 | { |
1769 | m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID); | 1801 | RegionInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID); |
1770 | m_eventManager.TriggerOnSaveNewWindlightProfile(); | 1802 | m_eventManager.TriggerOnSaveNewWindlightProfile(); |
1771 | } | 1803 | } |
1772 | 1804 | ||
@@ -2085,9 +2117,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2085 | sceneObject.SetGroup(groupID, null); | 2117 | sceneObject.SetGroup(groupID, null); |
2086 | } | 2118 | } |
2087 | 2119 | ||
2088 | IUserManagement uman = RequestModuleInterface<IUserManagement>(); | 2120 | if (UserManagementModule != null) |
2089 | if (uman != null) | 2121 | sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); |
2090 | sceneObject.RootPart.CreatorIdentification = uman.GetUserUUI(ownerID); | ||
2091 | 2122 | ||
2092 | sceneObject.ScheduleGroupForFullUpdate(); | 2123 | sceneObject.ScheduleGroupForFullUpdate(); |
2093 | 2124 | ||
@@ -2252,13 +2283,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
2252 | /// <summary> | 2283 | /// <summary> |
2253 | /// Synchronously delete the given object from the scene. | 2284 | /// Synchronously delete the given object from the scene. |
2254 | /// </summary> | 2285 | /// </summary> |
2286 | /// <remarks> | ||
2287 | /// Scripts are also removed. | ||
2288 | /// </remarks> | ||
2255 | /// <param name="group">Object Id</param> | 2289 | /// <param name="group">Object Id</param> |
2256 | /// <param name="silent">Suppress broadcasting changes to other clients.</param> | 2290 | /// <param name="silent">Suppress broadcasting changes to other clients.</param> |
2257 | public void DeleteSceneObject(SceneObjectGroup group, bool silent) | 2291 | public void DeleteSceneObject(SceneObjectGroup group, bool silent) |
2292 | { | ||
2293 | DeleteSceneObject(group, silent, true); | ||
2294 | } | ||
2295 | |||
2296 | /// <summary> | ||
2297 | /// Synchronously delete the given object from the scene. | ||
2298 | /// </summary> | ||
2299 | /// <param name="group">Object Id</param> | ||
2300 | /// <param name="silent">Suppress broadcasting changes to other clients.</param> | ||
2301 | /// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para> | ||
2302 | public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts) | ||
2258 | { | 2303 | { |
2259 | // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); | 2304 | // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); |
2260 | 2305 | ||
2261 | group.RemoveScriptInstances(true); | 2306 | if (removeScripts) |
2307 | group.RemoveScriptInstances(true); | ||
2308 | else | ||
2309 | group.StopScriptInstances(); | ||
2262 | 2310 | ||
2263 | SceneObjectPart[] partList = group.Parts; | 2311 | SceneObjectPart[] partList = group.Parts; |
2264 | 2312 | ||
@@ -2308,7 +2356,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2308 | ForceSceneObjectBackup(so); | 2356 | ForceSceneObjectBackup(so); |
2309 | 2357 | ||
2310 | so.DetachFromBackup(); | 2358 | so.DetachFromBackup(); |
2311 | SimulationDataService.RemoveObject(so.UUID, m_regInfo.RegionID); | 2359 | SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID); |
2312 | } | 2360 | } |
2313 | 2361 | ||
2314 | // We need to keep track of this state in case this group is still queued for further backup. | 2362 | // We need to keep track of this state in case this group is still queued for further backup. |
@@ -2365,8 +2413,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2365 | return; | 2413 | return; |
2366 | } | 2414 | } |
2367 | 2415 | ||
2368 | if (m_teleportModule != null) | 2416 | if (EntityTransferModule != null) |
2369 | m_teleportModule.Cross(grp, attemptedPosition, silent); | 2417 | EntityTransferModule.Cross(grp, attemptedPosition, silent); |
2370 | } | 2418 | } |
2371 | 2419 | ||
2372 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) | 2420 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) |
@@ -2566,7 +2614,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2566 | } | 2614 | } |
2567 | catch (Exception e) | 2615 | catch (Exception e) |
2568 | { | 2616 | { |
2569 | m_log.WarnFormat("[SCENE]: Problem casting object, exception {0}{1}", e.Message, e.StackTrace); | 2617 | m_log.WarnFormat("[INTERREGION]: Problem casting object, exception {0}{1}", e.Message, e.StackTrace); |
2618 | return false; | ||
2619 | } | ||
2620 | |||
2621 | // If the user is banned, we won't let any of their objects | ||
2622 | // enter. Period. | ||
2623 | // | ||
2624 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) | ||
2625 | { | ||
2626 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | ||
2570 | return false; | 2627 | return false; |
2571 | } | 2628 | } |
2572 | 2629 | ||
@@ -2577,32 +2634,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
2577 | 2634 | ||
2578 | if (!AddSceneObject(newObject)) | 2635 | if (!AddSceneObject(newObject)) |
2579 | { | 2636 | { |
2580 | m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); | 2637 | m_log.DebugFormat( |
2638 | "[INTERREGION]: Problem adding scene object {0} in {1} ", newObject.UUID, RegionInfo.RegionName); | ||
2581 | return false; | 2639 | return false; |
2582 | } | 2640 | } |
2583 | 2641 | ||
2584 | // For attachments, we need to wait until the agent is root | ||
2585 | // before we restart the scripts, or else some functions won't work. | ||
2586 | if (!newObject.IsAttachment) | 2642 | if (!newObject.IsAttachment) |
2587 | { | 2643 | { |
2588 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); | 2644 | // FIXME: It would be better to never add the scene object at all rather than add it and then delete |
2589 | newObject.ResumeScripts(); | 2645 | // it |
2590 | } | 2646 | if (!Permissions.CanObjectEntry(newObject.UUID, true, newObject.AbsolutePosition)) |
2591 | else | ||
2592 | { | ||
2593 | ScenePresence sp; | ||
2594 | if (TryGetScenePresence(newObject.OwnerID, out sp)) | ||
2595 | { | 2647 | { |
2596 | // If the scene presence is here and already a root | 2648 | // Deny non attachments based on parcel settings |
2597 | // agent, we came from a ;egacy region. Start the scripts | 2649 | // |
2598 | // here as they used to start. | 2650 | m_log.Info("[INTERREGION]: Denied prim crossing because of parcel settings"); |
2599 | // TODO: Remove in 0.7.3 | 2651 | |
2600 | if (!sp.IsChildAgent) | 2652 | DeleteSceneObject(newObject, false); |
2601 | { | 2653 | |
2602 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); | 2654 | return false; |
2603 | newObject.ResumeScripts(); | ||
2604 | } | ||
2605 | } | 2655 | } |
2656 | |||
2657 | // For attachments, we need to wait until the agent is root | ||
2658 | // before we restart the scripts, or else some functions won't work. | ||
2659 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); | ||
2660 | newObject.ResumeScripts(); | ||
2606 | } | 2661 | } |
2607 | 2662 | ||
2608 | // Do this as late as possible so that listeners have full access to the incoming object | 2663 | // Do this as late as possible so that listeners have full access to the incoming object |
@@ -2612,28 +2667,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2612 | } | 2667 | } |
2613 | 2668 | ||
2614 | /// <summary> | 2669 | /// <summary> |
2615 | /// Attachment rezzing | ||
2616 | /// </summary> | ||
2617 | /// <param name="userID">Agent Unique ID</param> | ||
2618 | /// <param name="itemID">Object ID</param> | ||
2619 | /// <returns>False</returns> | ||
2620 | public virtual bool IncomingCreateObject(UUID userID, UUID itemID) | ||
2621 | { | ||
2622 | m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); | ||
2623 | |||
2624 | // Commented out since this is as yet unused and is arguably not the appropriate place to do this, as | ||
2625 | // attachments are being rezzed elsewhere in AddNewClient() | ||
2626 | // ScenePresence sp = GetScenePresence(userID); | ||
2627 | // if (sp != null && AttachmentsModule != null) | ||
2628 | // { | ||
2629 | // uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); | ||
2630 | // AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt); | ||
2631 | // } | ||
2632 | |||
2633 | return false; | ||
2634 | } | ||
2635 | |||
2636 | /// <summary> | ||
2637 | /// Adds a Scene Object group to the Scene. | 2670 | /// Adds a Scene Object group to the Scene. |
2638 | /// Verifies that the creator of the object is not banned from the simulator. | 2671 | /// Verifies that the creator of the object is not banned from the simulator. |
2639 | /// Checks if the item is an Attachment | 2672 | /// Checks if the item is an Attachment |
@@ -2652,15 +2685,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2652 | // enter. Period. | 2685 | // enter. Period. |
2653 | // | 2686 | // |
2654 | int flags = GetUserFlags(sceneObject.OwnerID); | 2687 | int flags = GetUserFlags(sceneObject.OwnerID); |
2655 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | 2688 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) |
2656 | { | 2689 | { |
2657 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2690 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2658 | 2691 | ||
2659 | return false; | 2692 | return false; |
2660 | } | 2693 | } |
2661 | 2694 | ||
2662 | sceneObject.SetScene(this); | ||
2663 | |||
2664 | // Force allocation of new LocalId | 2695 | // Force allocation of new LocalId |
2665 | // | 2696 | // |
2666 | SceneObjectPart[] parts = sceneObject.Parts; | 2697 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2686,10 +2717,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2686 | { | 2717 | { |
2687 | SceneObjectGroup grp = sceneObject; | 2718 | SceneObjectGroup grp = sceneObject; |
2688 | 2719 | ||
2689 | m_log.DebugFormat( | 2720 | // m_log.DebugFormat( |
2690 | "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); | 2721 | // "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); |
2691 | m_log.DebugFormat( | 2722 | // m_log.DebugFormat( |
2692 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); | 2723 | // "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); |
2693 | 2724 | ||
2694 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2725 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2695 | 2726 | ||
@@ -2716,18 +2747,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2716 | return false; | 2747 | return false; |
2717 | } | 2748 | } |
2718 | AddRestoredSceneObject(sceneObject, true, false); | 2749 | AddRestoredSceneObject(sceneObject, true, false); |
2719 | |||
2720 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | ||
2721 | true, sceneObject.AbsolutePosition)) | ||
2722 | { | ||
2723 | // Deny non attachments based on parcel settings | ||
2724 | // | ||
2725 | m_log.Info("[INTERREGION]: Denied prim crossing because of parcel settings"); | ||
2726 | |||
2727 | DeleteSceneObject(sceneObject, false); | ||
2728 | |||
2729 | return false; | ||
2730 | } | ||
2731 | } | 2750 | } |
2732 | 2751 | ||
2733 | return true; | 2752 | return true; |
@@ -2785,7 +2804,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2785 | if (sp == null) | 2804 | if (sp == null) |
2786 | { | 2805 | { |
2787 | m_log.DebugFormat( | 2806 | m_log.DebugFormat( |
2788 | "[SCENE]: Adding new child scene presence {0} to scene {1} at pos {2}", client.Name, RegionInfo.RegionName, client.StartPos); | 2807 | "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}", |
2808 | client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos); | ||
2789 | 2809 | ||
2790 | m_clientManager.Add(client); | 2810 | m_clientManager.Add(client); |
2791 | SubscribeToClientEvents(client); | 2811 | SubscribeToClientEvents(client); |
@@ -2845,14 +2865,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2845 | /// <param name="aCircuit"></param> | 2865 | /// <param name="aCircuit"></param> |
2846 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) | 2866 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) |
2847 | { | 2867 | { |
2848 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | 2868 | if (UserManagementModule != null) |
2849 | if (uMan != null) | ||
2850 | { | 2869 | { |
2851 | string first = aCircuit.firstname, last = aCircuit.lastname; | 2870 | string first = aCircuit.firstname, last = aCircuit.lastname; |
2852 | 2871 | ||
2853 | if (sp.PresenceType == PresenceType.Npc) | 2872 | if (sp.PresenceType == PresenceType.Npc) |
2854 | { | 2873 | { |
2855 | uMan.AddUser(aCircuit.AgentID, first, last); | 2874 | UserManagementModule.AddUser(aCircuit.AgentID, first, last); |
2856 | } | 2875 | } |
2857 | else | 2876 | else |
2858 | { | 2877 | { |
@@ -2871,7 +2890,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2871 | } | 2890 | } |
2872 | } | 2891 | } |
2873 | 2892 | ||
2874 | uMan.AddUser(aCircuit.AgentID, first, last, homeURL); | 2893 | UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL); |
2875 | } | 2894 | } |
2876 | } | 2895 | } |
2877 | } | 2896 | } |
@@ -3209,8 +3228,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3209 | /// <param name="client">The IClientAPI for the client</param> | 3228 | /// <param name="client">The IClientAPI for the client</param> |
3210 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) | 3229 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3211 | { | 3230 | { |
3212 | if (m_teleportModule != null) | 3231 | if (EntityTransferModule != null) |
3213 | return m_teleportModule.TeleportHome(agentId, client); | 3232 | { |
3233 | EntityTransferModule.TeleportHome(agentId, client); | ||
3234 | } | ||
3214 | else | 3235 | else |
3215 | { | 3236 | { |
3216 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3237 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
@@ -3372,65 +3393,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
3372 | // CheckHeartbeat(); | 3393 | // CheckHeartbeat(); |
3373 | bool isChildAgent = false; | 3394 | bool isChildAgent = false; |
3374 | ScenePresence avatar = GetScenePresence(agentID); | 3395 | ScenePresence avatar = GetScenePresence(agentID); |
3375 | if (avatar != null) | 3396 | |
3397 | if (avatar == null) | ||
3398 | { | ||
3399 | m_log.WarnFormat( | ||
3400 | "[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID); | ||
3401 | |||
3402 | return; | ||
3403 | } | ||
3404 | |||
3405 | try | ||
3376 | { | 3406 | { |
3377 | isChildAgent = avatar.IsChildAgent; | 3407 | isChildAgent = avatar.IsChildAgent; |
3378 | 3408 | ||
3379 | if (avatar.ParentID != 0) | 3409 | m_log.DebugFormat( |
3410 | "[SCENE]: Removing {0} agent {1} {2} from {3}", | ||
3411 | (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName); | ||
3412 | |||
3413 | // Don't do this to root agents, it's not nice for the viewer | ||
3414 | if (closeChildAgents && isChildAgent) | ||
3380 | { | 3415 | { |
3381 | avatar.StandUp(); | 3416 | // Tell a single agent to disconnect from the region. |
3417 | IEventQueue eq = RequestModuleInterface<IEventQueue>(); | ||
3418 | if (eq != null) | ||
3419 | { | ||
3420 | eq.DisableSimulator(RegionInfo.RegionHandle, avatar.UUID); | ||
3421 | } | ||
3422 | else | ||
3423 | { | ||
3424 | avatar.ControllingClient.SendShutdownConnectionNotice(); | ||
3425 | } | ||
3382 | } | 3426 | } |
3383 | 3427 | ||
3384 | try | 3428 | // Only applies to root agents. |
3429 | if (avatar.ParentID != 0) | ||
3385 | { | 3430 | { |
3386 | m_log.DebugFormat( | 3431 | avatar.StandUp(); |
3387 | "[SCENE]: Removing {0} agent {1} from region {2}", | 3432 | } |
3388 | (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName); | ||
3389 | 3433 | ||
3390 | m_sceneGraph.removeUserCount(!isChildAgent); | 3434 | m_sceneGraph.removeUserCount(!isChildAgent); |
3391 | 3435 | ||
3392 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 3436 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3393 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 3437 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3394 | if (closeChildAgents && CapsModule != null) | 3438 | if (closeChildAgents && CapsModule != null) |
3395 | CapsModule.RemoveCaps(agentID); | 3439 | CapsModule.RemoveCaps(agentID); |
3396 | 3440 | ||
3397 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever | 3441 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3398 | // this method is doing is HORRIBLE!!! | 3442 | // this method is doing is HORRIBLE!!! |
3399 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); | 3443 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); |
3400 | 3444 | ||
3401 | if (closeChildAgents && !avatar.IsChildAgent) | 3445 | if (closeChildAgents && !isChildAgent) |
3402 | { | ||
3403 | List<ulong> regions = avatar.KnownRegionHandles; | ||
3404 | regions.Remove(RegionInfo.RegionHandle); | ||
3405 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | ||
3406 | } | ||
3407 | m_log.Debug("[Scene] Beginning ClientClosed"); | ||
3408 | m_eventManager.TriggerClientClosed(agentID, this); | ||
3409 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3410 | } | ||
3411 | catch (NullReferenceException) | ||
3412 | { | 3446 | { |
3413 | // We don't know which count to remove it from | 3447 | List<ulong> regions = avatar.KnownRegionHandles; |
3414 | // Avatar is already disposed :/ | 3448 | regions.Remove(RegionInfo.RegionHandle); |
3449 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | ||
3415 | } | 3450 | } |
3416 | 3451 | ||
3417 | try | 3452 | m_eventManager.TriggerClientClosed(agentID, this); |
3453 | m_eventManager.TriggerOnRemovePresence(agentID); | ||
3454 | |||
3455 | if (!isChildAgent) | ||
3418 | { | 3456 | { |
3419 | m_eventManager.TriggerOnRemovePresence(agentID); | 3457 | if (AttachmentsModule != null) |
3420 | |||
3421 | if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3422 | { | 3458 | { |
3423 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | ||
3424 | // Don't save attachments for HG visitors, it | 3459 | // Don't save attachments for HG visitors, it |
3425 | // messes up their inventory. When a HG visitor logs | 3460 | // messes up their inventory. When a HG visitor logs |
3426 | // out on a foreign grid, their attachments will be | 3461 | // out on a foreign grid, their attachments will be |
3427 | // reloaded in the state they were in when they left | 3462 | // reloaded in the state they were in when they left |
3428 | // the home grid. This is best anyway as the visited | 3463 | // the home grid. This is best anyway as the visited |
3429 | // grid may use an incompatible script engine. | 3464 | // grid may use an incompatible script engine. |
3430 | if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) | 3465 | bool saveChanged |
3431 | AttachmentsModule.SaveChangedAttachments(avatar, false); | 3466 | = avatar.PresenceType != PresenceType.Npc |
3467 | && (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID)); | ||
3468 | |||
3469 | AttachmentsModule.DeRezAttachments(avatar, saveChanged, false); | ||
3432 | } | 3470 | } |
3433 | 3471 | ||
3434 | ForEachClient( | 3472 | ForEachClient( |
3435 | delegate(IClientAPI client) | 3473 | delegate(IClientAPI client) |
3436 | { | 3474 | { |
@@ -3438,43 +3476,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
3438 | try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); } | 3476 | try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); } |
3439 | catch (NullReferenceException) { } | 3477 | catch (NullReferenceException) { } |
3440 | }); | 3478 | }); |
3441 | |||
3442 | IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | ||
3443 | if (agentTransactions != null) | ||
3444 | { | ||
3445 | agentTransactions.RemoveAgentAssetTransactions(agentID); | ||
3446 | } | ||
3447 | } | ||
3448 | finally | ||
3449 | { | ||
3450 | // Always clean these structures up so that any failure above doesn't cause them to remain in the | ||
3451 | // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering | ||
3452 | // the same cleanup exception continually. | ||
3453 | // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE | ||
3454 | // since this would hide the underlying failure and other associated problems. | ||
3455 | m_sceneGraph.RemoveScenePresence(agentID); | ||
3456 | m_clientManager.Remove(agentID); | ||
3457 | } | 3479 | } |
3458 | 3480 | ||
3459 | try | 3481 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3460 | { | 3482 | if (AgentTransactionsModule != null) |
3461 | avatar.Close(); | 3483 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3462 | } | 3484 | |
3463 | catch (NullReferenceException) | 3485 | avatar.Close(); |
3464 | { | 3486 | |
3465 | //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. | ||
3466 | } | ||
3467 | catch (Exception e) | ||
3468 | { | ||
3469 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | ||
3470 | } | ||
3471 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | ||
3472 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3487 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3473 | // CleanDroppedAttachments(); | ||
3474 | m_log.Debug("[Scene] The avatar has left the building"); | 3488 | m_log.Debug("[Scene] The avatar has left the building"); |
3475 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | ||
3476 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | ||
3477 | } | 3489 | } |
3490 | catch (Exception e) | ||
3491 | { | ||
3492 | m_log.Error( | ||
3493 | string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e); | ||
3494 | } | ||
3495 | finally | ||
3496 | { | ||
3497 | // Always clean these structures up so that any failure above doesn't cause them to remain in the | ||
3498 | // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering | ||
3499 | // the same cleanup exception continually. | ||
3500 | // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE | ||
3501 | // since this would hide the underlying failure and other associated problems. | ||
3502 | m_sceneGraph.RemoveScenePresence(agentID); | ||
3503 | m_clientManager.Remove(agentID); | ||
3504 | } | ||
3505 | |||
3506 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | ||
3507 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | ||
3478 | } | 3508 | } |
3479 | 3509 | ||
3480 | /// <summary> | 3510 | /// <summary> |
@@ -3556,7 +3586,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3556 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) | 3586 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) |
3557 | { | 3587 | { |
3558 | bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || | 3588 | bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || |
3559 | (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); | 3589 | (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); |
3560 | bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); | 3590 | bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); |
3561 | bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); | 3591 | bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); |
3562 | 3592 | ||
@@ -3572,8 +3602,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3572 | // Don't disable this log message - it's too helpful | 3602 | // Don't disable this log message - it's too helpful |
3573 | m_log.DebugFormat( | 3603 | m_log.DebugFormat( |
3574 | "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})", | 3604 | "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})", |
3575 | RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname, | 3605 | RegionInfo.RegionName, |
3576 | agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); | 3606 | (agent.child ? "child" : "root"), |
3607 | agent.firstname, | ||
3608 | agent.lastname, | ||
3609 | agent.AgentID, | ||
3610 | agent.circuitcode, | ||
3611 | agent.IPAddress, | ||
3612 | agent.Viewer, | ||
3613 | ((TPFlags)teleportFlags).ToString(), | ||
3614 | agent.startpos | ||
3615 | ); | ||
3577 | 3616 | ||
3578 | if (LoginsDisabled) | 3617 | if (LoginsDisabled) |
3579 | { | 3618 | { |
@@ -3581,6 +3620,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3581 | return false; | 3620 | return false; |
3582 | } | 3621 | } |
3583 | 3622 | ||
3623 | //Check if the viewer is banned or in the viewer access list | ||
3624 | //We check if the substring is listed for higher flexebility | ||
3625 | bool ViewerDenied = true; | ||
3626 | |||
3627 | //Check if the specific viewer is listed in the allowed viewer list | ||
3628 | if (m_AllowedViewers.Count > 0) | ||
3629 | { | ||
3630 | foreach (string viewer in m_AllowedViewers) | ||
3631 | { | ||
3632 | if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower()) | ||
3633 | { | ||
3634 | ViewerDenied = false; | ||
3635 | break; | ||
3636 | } | ||
3637 | } | ||
3638 | } | ||
3639 | else | ||
3640 | { | ||
3641 | ViewerDenied = false; | ||
3642 | } | ||
3643 | |||
3644 | //Check if the viewer is in the banned list | ||
3645 | if (m_BannedViewers.Count > 0) | ||
3646 | { | ||
3647 | foreach (string viewer in m_BannedViewers) | ||
3648 | { | ||
3649 | if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower()) | ||
3650 | { | ||
3651 | ViewerDenied = true; | ||
3652 | break; | ||
3653 | } | ||
3654 | } | ||
3655 | } | ||
3656 | |||
3657 | if (ViewerDenied) | ||
3658 | { | ||
3659 | m_log.DebugFormat( | ||
3660 | "[SCENE]: Access denied for {0} {1} using {2}", | ||
3661 | agent.firstname, agent.lastname, agent.Viewer); | ||
3662 | reason = "Access denied, your viewer is banned by the region owner"; | ||
3663 | return false; | ||
3664 | } | ||
3665 | |||
3666 | |||
3584 | ScenePresence sp = GetScenePresence(agent.AgentID); | 3667 | ScenePresence sp = GetScenePresence(agent.AgentID); |
3585 | 3668 | ||
3586 | if (sp != null && !sp.IsChildAgent) | 3669 | if (sp != null && !sp.IsChildAgent) |
@@ -3588,7 +3671,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3588 | // We have a zombie from a crashed session. | 3671 | // We have a zombie from a crashed session. |
3589 | // Or the same user is trying to be root twice here, won't work. | 3672 | // Or the same user is trying to be root twice here, won't work. |
3590 | // Kill it. | 3673 | // Kill it. |
3591 | m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); | 3674 | m_log.DebugFormat( |
3675 | "[SCENE]: Zombie scene presence detected for {0} {1} in {2}", | ||
3676 | sp.Name, sp.UUID, RegionInfo.RegionName); | ||
3677 | |||
3592 | sp.ControllingClient.Close(); | 3678 | sp.ControllingClient.Close(); |
3593 | sp = null; | 3679 | sp = null; |
3594 | } | 3680 | } |
@@ -3615,8 +3701,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3615 | { | 3701 | { |
3616 | if (!VerifyUserPresence(agent, out reason)) | 3702 | if (!VerifyUserPresence(agent, out reason)) |
3617 | return false; | 3703 | return false; |
3618 | } | 3704 | } catch (Exception e) |
3619 | catch (Exception e) | ||
3620 | { | 3705 | { |
3621 | m_log.ErrorFormat( | 3706 | m_log.ErrorFormat( |
3622 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); | 3707 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); |
@@ -3651,8 +3736,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3651 | CapsModule.SetAgentCapsSeeds(agent); | 3736 | CapsModule.SetAgentCapsSeeds(agent); |
3652 | CapsModule.CreateCaps(agent.AgentID); | 3737 | CapsModule.CreateCaps(agent.AgentID); |
3653 | } | 3738 | } |
3654 | } | 3739 | } else |
3655 | else | ||
3656 | { | 3740 | { |
3657 | // Let the SP know how we got here. This has a lot of interesting | 3741 | // Let the SP know how we got here. This has a lot of interesting |
3658 | // uses down the line. | 3742 | // uses down the line. |
@@ -3675,7 +3759,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3675 | agent.teleportFlags = teleportFlags; | 3759 | agent.teleportFlags = teleportFlags; |
3676 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3760 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3677 | 3761 | ||
3678 | if (vialogin) | 3762 | if (vialogin) |
3679 | { | 3763 | { |
3680 | // CleanDroppedAttachments(); | 3764 | // CleanDroppedAttachments(); |
3681 | 3765 | ||
@@ -3716,8 +3800,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3716 | agent.startpos.Z = 720; | 3800 | agent.startpos.Z = 720; |
3717 | } | 3801 | } |
3718 | } | 3802 | } |
3719 | } | 3803 | } else |
3720 | else | ||
3721 | { | 3804 | { |
3722 | if (agent.startpos.X > EastBorders[0].BorderLine.Z) | 3805 | if (agent.startpos.X > EastBorders[0].BorderLine.Z) |
3723 | { | 3806 | { |
@@ -3743,10 +3826,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3743 | SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); | 3826 | SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); |
3744 | // Can have multiple SpawnPoints | 3827 | // Can have multiple SpawnPoints |
3745 | List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); | 3828 | List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); |
3746 | if ( spawnpoints.Count > 1) | 3829 | if (spawnpoints.Count > 1) |
3747 | { | 3830 | { |
3748 | // We have multiple SpawnPoints, Route the agent to a random one | 3831 | // We have multiple SpawnPoints, Route the agent to a random or sequential one |
3749 | agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count)].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); | 3832 | if (SpawnPointRouting == "random") |
3833 | agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation( | ||
3834 | telehub.AbsolutePosition, | ||
3835 | telehub.GroupRotation | ||
3836 | ); | ||
3837 | else | ||
3838 | agent.startpos = spawnpoints[SpawnPoint()].GetLocation( | ||
3839 | telehub.AbsolutePosition, | ||
3840 | telehub.GroupRotation | ||
3841 | ); | ||
3750 | } | 3842 | } |
3751 | else | 3843 | else |
3752 | { | 3844 | { |
@@ -3869,9 +3961,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3869 | } | 3961 | } |
3870 | } | 3962 | } |
3871 | 3963 | ||
3872 | if (m_regInfo.EstateSettings != null) | 3964 | if (RegionInfo.EstateSettings != null) |
3873 | { | 3965 | { |
3874 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) | 3966 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3875 | { | 3967 | { |
3876 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3968 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3877 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3969 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3903,7 +3995,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3903 | } | 3995 | } |
3904 | 3996 | ||
3905 | bool groupAccess = false; | 3997 | bool groupAccess = false; |
3906 | UUID[] estateGroups = m_regInfo.EstateSettings.EstateGroups; | 3998 | UUID[] estateGroups = RegionInfo.EstateSettings.EstateGroups; |
3907 | 3999 | ||
3908 | if (estateGroups != null) | 4000 | if (estateGroups != null) |
3909 | { | 4001 | { |
@@ -3921,8 +4013,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3921 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); | 4013 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); |
3922 | } | 4014 | } |
3923 | 4015 | ||
3924 | if (!m_regInfo.EstateSettings.PublicAccess && | 4016 | if (!RegionInfo.EstateSettings.PublicAccess && |
3925 | !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && | 4017 | !RegionInfo.EstateSettings.HasAccess(agent.AgentID) && |
3926 | !groupAccess) | 4018 | !groupAccess) |
3927 | { | 4019 | { |
3928 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", | 4020 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", |
@@ -3983,41 +4075,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
3983 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); | 4075 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); |
3984 | } | 4076 | } |
3985 | 4077 | ||
3986 | /// <summary> | 4078 | // /// <summary> |
3987 | /// The Grid has requested that we log-off a user. Log them off. | 4079 | // /// The Grid has requested that we log-off a user. Log them off. |
3988 | /// </summary> | 4080 | // /// </summary> |
3989 | /// <param name="AvatarID">Unique ID of the avatar to log-off</param> | 4081 | // /// <param name="AvatarID">Unique ID of the avatar to log-off</param> |
3990 | /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> | 4082 | // /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> |
3991 | /// <param name="message">message to display to the user. Reason for being logged off</param> | 4083 | // /// <param name="message">message to display to the user. Reason for being logged off</param> |
3992 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) | 4084 | // public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) |
3993 | { | 4085 | // { |
3994 | ScenePresence loggingOffUser = GetScenePresence(AvatarID); | 4086 | // ScenePresence loggingOffUser = GetScenePresence(AvatarID); |
3995 | if (loggingOffUser != null) | 4087 | // if (loggingOffUser != null) |
3996 | { | 4088 | // { |
3997 | UUID localRegionSecret = UUID.Zero; | 4089 | // UUID localRegionSecret = UUID.Zero; |
3998 | bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); | 4090 | // bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret); |
3999 | 4091 | // | |
4000 | // Region Secret is used here in case a new sessionid overwrites an old one on the user server. | 4092 | // // Region Secret is used here in case a new sessionid overwrites an old one on the user server. |
4001 | // Will update the user server in a few revisions to use it. | 4093 | // // Will update the user server in a few revisions to use it. |
4002 | 4094 | // | |
4003 | if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) | 4095 | // if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) |
4004 | { | 4096 | // { |
4005 | m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); | 4097 | // m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); |
4006 | loggingOffUser.ControllingClient.Kick(message); | 4098 | // loggingOffUser.ControllingClient.Kick(message); |
4007 | // Give them a second to receive the message! | 4099 | // // Give them a second to receive the message! |
4008 | Thread.Sleep(1000); | 4100 | // Thread.Sleep(1000); |
4009 | loggingOffUser.ControllingClient.Close(); | 4101 | // loggingOffUser.ControllingClient.Close(); |
4010 | } | 4102 | // } |
4011 | else | 4103 | // else |
4012 | { | 4104 | // { |
4013 | m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); | 4105 | // m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); |
4014 | } | 4106 | // } |
4015 | } | 4107 | // } |
4016 | else | 4108 | // else |
4017 | { | 4109 | // { |
4018 | m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); | 4110 | // m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); |
4019 | } | 4111 | // } |
4020 | } | 4112 | // } |
4021 | 4113 | ||
4022 | /// <summary> | 4114 | /// <summary> |
4023 | /// Triggered when an agent crosses into this sim. Also happens on initial login. | 4115 | /// Triggered when an agent crosses into this sim. Also happens on initial login. |
@@ -4070,21 +4162,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
4070 | return false; | 4162 | return false; |
4071 | } | 4163 | } |
4072 | 4164 | ||
4165 | // TODO: This check should probably be in QueryAccess(). | ||
4073 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4166 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4074 | if (nearestParcel == null) | 4167 | if (nearestParcel == null) |
4075 | { | 4168 | { |
4076 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); | 4169 | m_log.DebugFormat( |
4077 | return false; | 4170 | "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel", |
4078 | } | 4171 | cAgentData.AgentID, RegionInfo.RegionName); |
4079 | |||
4080 | int num = m_sceneGraph.GetNumberOfScenePresences(); | ||
4081 | 4172 | ||
4082 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 4173 | return false; |
4083 | { | ||
4084 | if (!Permissions.IsAdministrator(cAgentData.AgentID)) | ||
4085 | return false; | ||
4086 | } | 4174 | } |
4087 | 4175 | ||
4176 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4177 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4088 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 4178 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
4089 | 4179 | ||
4090 | if (childAgentUpdate != null) | 4180 | if (childAgentUpdate != null) |
@@ -4128,14 +4218,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
4128 | return false; | 4218 | return false; |
4129 | } | 4219 | } |
4130 | 4220 | ||
4221 | /// <summary> | ||
4222 | /// Poll until the requested ScenePresence appears or we timeout. | ||
4223 | /// </summary> | ||
4224 | /// <returns>The scene presence is found, else null.</returns> | ||
4225 | /// <param name='agentID'></param> | ||
4131 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4226 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4132 | { | 4227 | { |
4133 | int ntimes = 10; | 4228 | int ntimes = 10; |
4134 | ScenePresence childAgentUpdate = null; | 4229 | ScenePresence sp = null; |
4135 | while ((childAgentUpdate = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4230 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4136 | Thread.Sleep(1000); | 4231 | Thread.Sleep(1000); |
4137 | return childAgentUpdate; | ||
4138 | 4232 | ||
4233 | if (sp == null) | ||
4234 | m_log.WarnFormat( | ||
4235 | "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout", | ||
4236 | agentID, RegionInfo.RegionName); | ||
4237 | // else | ||
4238 | // m_log.DebugFormat( | ||
4239 | // "[SCENE PRESENCE]: Found presence {0} {1} {2} in {3} after {4} waits", | ||
4240 | // sp.Name, sp.UUID, sp.IsChildAgent ? "child" : "root", RegionInfo.RegionName, 10 - ntimes); | ||
4241 | |||
4242 | return sp; | ||
4139 | } | 4243 | } |
4140 | 4244 | ||
4141 | public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) | 4245 | public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) |
@@ -4173,33 +4277,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4173 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4277 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4174 | if (presence != null) | 4278 | if (presence != null) |
4175 | { | 4279 | { |
4176 | // Nothing is removed here, so down count it as such | 4280 | presence.ControllingClient.Close(); |
4177 | if (presence.IsChildAgent) | ||
4178 | { | ||
4179 | m_sceneGraph.removeUserCount(false); | ||
4180 | } | ||
4181 | else if (!childOnly) | ||
4182 | { | ||
4183 | m_sceneGraph.removeUserCount(true); | ||
4184 | } | ||
4185 | |||
4186 | // Don't do this to root agents on logout, it's not nice for the viewer | ||
4187 | if (presence.IsChildAgent) | ||
4188 | { | ||
4189 | // Tell a single agent to disconnect from the region. | ||
4190 | IEventQueue eq = RequestModuleInterface<IEventQueue>(); | ||
4191 | if (eq != null) | ||
4192 | { | ||
4193 | eq.DisableSimulator(RegionInfo.RegionHandle, agentID); | ||
4194 | } | ||
4195 | else | ||
4196 | presence.ControllingClient.SendShutdownConnectionNotice(); | ||
4197 | presence.ControllingClient.Close(false); | ||
4198 | } | ||
4199 | else if (!childOnly) | ||
4200 | { | ||
4201 | presence.ControllingClient.Close(true); | ||
4202 | } | ||
4203 | return true; | 4281 | return true; |
4204 | } | 4282 | } |
4205 | 4283 | ||
@@ -4247,13 +4325,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4247 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); | 4325 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); |
4248 | if (sp != null) | 4326 | if (sp != null) |
4249 | { | 4327 | { |
4250 | uint regionX = m_regInfo.RegionLocX; | 4328 | uint regionX = RegionInfo.RegionLocX; |
4251 | uint regionY = m_regInfo.RegionLocY; | 4329 | uint regionY = RegionInfo.RegionLocY; |
4252 | 4330 | ||
4253 | Utils.LongToUInts(regionHandle, out regionX, out regionY); | 4331 | Utils.LongToUInts(regionHandle, out regionX, out regionY); |
4254 | 4332 | ||
4255 | int shiftx = (int) regionX - (int) m_regInfo.RegionLocX * (int)Constants.RegionSize; | 4333 | int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; |
4256 | int shifty = (int) regionY - (int) m_regInfo.RegionLocY * (int)Constants.RegionSize; | 4334 | int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; |
4257 | 4335 | ||
4258 | position.X += shiftx; | 4336 | position.X += shiftx; |
4259 | position.Y += shifty; | 4337 | position.Y += shifty; |
@@ -4276,7 +4354,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4276 | 4354 | ||
4277 | if (!result) | 4355 | if (!result) |
4278 | { | 4356 | { |
4279 | regionHandle = m_regInfo.RegionHandle; | 4357 | regionHandle = RegionInfo.RegionHandle; |
4280 | } | 4358 | } |
4281 | else | 4359 | else |
4282 | { | 4360 | { |
@@ -4285,8 +4363,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
4285 | position.Y -= shifty; | 4363 | position.Y -= shifty; |
4286 | } | 4364 | } |
4287 | 4365 | ||
4288 | if (m_teleportModule != null) | 4366 | if (EntityTransferModule != null) |
4289 | m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); | 4367 | { |
4368 | EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); | ||
4369 | } | ||
4290 | else | 4370 | else |
4291 | { | 4371 | { |
4292 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); | 4372 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); |
@@ -4297,8 +4377,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
4297 | 4377 | ||
4298 | public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) | 4378 | public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) |
4299 | { | 4379 | { |
4300 | if (m_teleportModule != null) | 4380 | if (EntityTransferModule != null) |
4301 | return m_teleportModule.Cross(agent, isFlying); | 4381 | { |
4382 | return EntityTransferModule.Cross(agent, isFlying); | ||
4383 | } | ||
4302 | else | 4384 | else |
4303 | { | 4385 | { |
4304 | m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); | 4386 | m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); |
@@ -4600,6 +4682,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4600 | } | 4682 | } |
4601 | 4683 | ||
4602 | /// <summary> | 4684 | /// <summary> |
4685 | /// Get all the scene object groups. | ||
4686 | /// </summary> | ||
4687 | /// <returns> | ||
4688 | /// The scene object groups. If the scene is empty then an empty list is returned. | ||
4689 | /// </returns> | ||
4690 | public List<SceneObjectGroup> GetSceneObjectGroups() | ||
4691 | { | ||
4692 | return m_sceneGraph.GetSceneObjectGroups(); | ||
4693 | } | ||
4694 | |||
4695 | /// <summary> | ||
4603 | /// Get a group via its UUID | 4696 | /// Get a group via its UUID |
4604 | /// </summary> | 4697 | /// </summary> |
4605 | /// <param name="fullID"></param> | 4698 | /// <param name="fullID"></param> |
@@ -4778,7 +4871,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4778 | 4871 | ||
4779 | public void DeleteFromStorage(UUID uuid) | 4872 | public void DeleteFromStorage(UUID uuid) |
4780 | { | 4873 | { |
4781 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4874 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4782 | } | 4875 | } |
4783 | 4876 | ||
4784 | public int GetHealth(out int flags, out string message) | 4877 | public int GetHealth(out int flags, out string message) |
@@ -5259,7 +5352,7 @@ Environment.Exit(1); | |||
5259 | IEstateDataService estateDataService = EstateDataService; | 5352 | IEstateDataService estateDataService = EstateDataService; |
5260 | if (estateDataService != null) | 5353 | if (estateDataService != null) |
5261 | { | 5354 | { |
5262 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); | 5355 | RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false); |
5263 | TriggerEstateSunUpdate(); | 5356 | TriggerEstateSunUpdate(); |
5264 | } | 5357 | } |
5265 | } | 5358 | } |
@@ -5446,29 +5539,58 @@ Environment.Exit(1); | |||
5446 | throw new Exception(error); | 5539 | throw new Exception(error); |
5447 | } | 5540 | } |
5448 | 5541 | ||
5449 | // This method is called across the simulation connector to | 5542 | /// <summary> |
5450 | // determine if a given agent is allowed in this region | 5543 | /// This method is called across the simulation connector to |
5451 | // AS A ROOT AGENT. Returning false here will prevent them | 5544 | /// determine if a given agent is allowed in this region |
5452 | // from logging into the region, teleporting into the region | 5545 | /// AS A ROOT AGENT |
5453 | // or corssing the broder walking, but will NOT prevent | 5546 | /// </summary> |
5454 | // child agent creation, thereby emulating the SL behavior. | 5547 | /// <remarks> |
5548 | /// Returning false here will prevent them | ||
5549 | /// from logging into the region, teleporting into the region | ||
5550 | /// or corssing the broder walking, but will NOT prevent | ||
5551 | /// child agent creation, thereby emulating the SL behavior. | ||
5552 | /// </remarks> | ||
5553 | /// <param name='agentID'></param> | ||
5554 | /// <param name='position'></param> | ||
5555 | /// <param name='reason'></param> | ||
5556 | /// <returns></returns> | ||
5455 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5557 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5456 | { | 5558 | { |
5457 | reason = "You are banned from the region"; | 5559 | reason = "You are banned from the region"; |
5458 | 5560 | ||
5561 | if (EntityTransferModule.IsInTransit(agentID)) | ||
5562 | { | ||
5563 | reason = "Agent is still in transit from this region"; | ||
5564 | |||
5565 | m_log.WarnFormat( | ||
5566 | "[SCENE]: Denying agent {0} entry into {1} since region still has them registered as in transit", | ||
5567 | agentID, RegionInfo.RegionName); | ||
5568 | |||
5569 | return false; | ||
5570 | } | ||
5571 | |||
5459 | if (Permissions.IsGod(agentID)) | 5572 | if (Permissions.IsGod(agentID)) |
5460 | { | 5573 | { |
5461 | reason = String.Empty; | 5574 | reason = String.Empty; |
5462 | return true; | 5575 | return true; |
5463 | } | 5576 | } |
5464 | 5577 | ||
5465 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5578 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5579 | // However, the long term fix is to make sure root agent count is always accurate. | ||
5580 | m_sceneGraph.RecalculateStats(); | ||
5581 | |||
5582 | int num = m_sceneGraph.GetRootAgentCount(); | ||
5466 | 5583 | ||
5467 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5584 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
5468 | { | 5585 | { |
5469 | if (!Permissions.IsAdministrator(agentID)) | 5586 | if (!Permissions.IsAdministrator(agentID)) |
5470 | { | 5587 | { |
5471 | reason = "The region is full"; | 5588 | reason = "The region is full"; |
5589 | |||
5590 | m_log.DebugFormat( | ||
5591 | "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}", | ||
5592 | agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit); | ||
5593 | |||
5472 | return false; | 5594 | return false; |
5473 | } | 5595 | } |
5474 | } | 5596 | } |
@@ -5640,6 +5762,20 @@ Environment.Exit(1); | |||
5640 | } | 5762 | } |
5641 | } | 5763 | } |
5642 | 5764 | ||
5765 | // manage and select spawn points in sequence | ||
5766 | public int SpawnPoint() | ||
5767 | { | ||
5768 | int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count; | ||
5769 | |||
5770 | if (spawnpoints == 0) | ||
5771 | return 0; | ||
5772 | |||
5773 | m_SpawnPoint++; | ||
5774 | if (m_SpawnPoint > spawnpoints) | ||
5775 | m_SpawnPoint = 1; | ||
5776 | return m_SpawnPoint - 1; | ||
5777 | } | ||
5778 | |||
5643 | private void HandleGcCollect(string module, string[] args) | 5779 | private void HandleGcCollect(string module, string[] args) |
5644 | { | 5780 | { |
5645 | GC.Collect(); | 5781 | GC.Collect(); |