aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs321
1 files changed, 212 insertions, 109 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a9a4cda..32c7262 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.
@@ -163,7 +169,6 @@ namespace OpenSim.Region.Framework.Scenes
163 protected IConfigSource m_config; 169 protected IConfigSource m_config;
164 protected IRegionSerialiserModule m_serialiser; 170 protected IRegionSerialiserModule m_serialiser;
165 protected IDialogModule m_dialogModule; 171 protected IDialogModule m_dialogModule;
166 protected IEntityTransferModule m_teleportModule;
167 protected ICapabilitiesModule m_capsModule; 172 protected ICapabilitiesModule m_capsModule;
168 protected IGroupsModule m_groupsModule; 173 protected IGroupsModule m_groupsModule;
169 174
@@ -458,6 +463,7 @@ namespace OpenSim.Region.Framework.Scenes
458 { 463 {
459 if (m_simulationService == null) 464 if (m_simulationService == null)
460 m_simulationService = RequestModuleInterface<ISimulationService>(); 465 m_simulationService = RequestModuleInterface<ISimulationService>();
466
461 return m_simulationService; 467 return m_simulationService;
462 } 468 }
463 } 469 }
@@ -513,6 +519,7 @@ namespace OpenSim.Region.Framework.Scenes
513 } 519 }
514 520
515 public IAttachmentsModule AttachmentsModule { get; set; } 521 public IAttachmentsModule AttachmentsModule { get; set; }
522 public IEntityTransferModule EntityTransferModule { get; private set; }
516 523
517 public IAvatarFactoryModule AvatarFactory 524 public IAvatarFactoryModule AvatarFactory
518 { 525 {
@@ -589,6 +596,20 @@ namespace OpenSim.Region.Framework.Scenes
589 get { return m_sceneGraph.Entities; } 596 get { return m_sceneGraph.Entities; }
590 } 597 }
591 598
599
600 // used in sequence see: SpawnPoint()
601 private int m_SpawnPoint;
602 // can be closest/random/sequence
603 public string SpawnPointRouting
604 {
605 get; private set;
606 }
607 // allow landmarks to pass
608 public bool TelehubAllowLandmarks
609 {
610 get; private set;
611 }
612
592 #endregion Properties 613 #endregion Properties
593 614
594 #region Constructors 615 #region Constructors
@@ -606,7 +627,7 @@ namespace OpenSim.Region.Framework.Scenes
606 627
607 Random random = new Random(); 628 Random random = new Random();
608 629
609 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 630 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
610 m_moduleLoader = moduleLoader; 631 m_moduleLoader = moduleLoader;
611 m_authenticateHandler = authen; 632 m_authenticateHandler = authen;
612 m_sceneGridService = sceneGridService; 633 m_sceneGridService = sceneGridService;
@@ -726,6 +747,9 @@ namespace OpenSim.Region.Framework.Scenes
726 m_maxPhys = RegionInfo.PhysPrimMax; 747 m_maxPhys = RegionInfo.PhysPrimMax;
727 } 748 }
728 749
750 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
751 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
752
729 // Here, if clamping is requested in either global or 753 // Here, if clamping is requested in either global or
730 // local config, it will be used 754 // local config, it will be used
731 // 755 //
@@ -735,6 +759,7 @@ namespace OpenSim.Region.Framework.Scenes
735 m_clampPrimSize = true; 759 m_clampPrimSize = true;
736 } 760 }
737 761
762 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
738 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 763 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
739 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 764 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
740 m_dontPersistBefore = 765 m_dontPersistBefore =
@@ -833,13 +858,11 @@ namespace OpenSim.Region.Framework.Scenes
833 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 858 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
834 } 859 }
835 860
836 /// <summary>
837 /// Mock constructor for scene group persistency unit tests.
838 /// SceneObjectGroup RegionId property is delegated to Scene.
839 /// </summary>
840 /// <param name="regInfo"></param>
841 public Scene(RegionInfo regInfo) 861 public Scene(RegionInfo regInfo)
842 { 862 {
863 PhysicalPrims = true;
864 CollidablePrims = true;
865
843 BordersLocked = true; 866 BordersLocked = true;
844 Border northBorder = new Border(); 867 Border northBorder = new Border();
845 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- 868 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<---
@@ -866,8 +889,6 @@ namespace OpenSim.Region.Framework.Scenes
866 m_eventManager = new EventManager(); 889 m_eventManager = new EventManager();
867 890
868 m_permissions = new ScenePermissions(this); 891 m_permissions = new ScenePermissions(this);
869
870// m_lastUpdate = Util.EnvironmentTickCount();
871 } 892 }
872 893
873 #endregion 894 #endregion
@@ -936,8 +957,8 @@ namespace OpenSim.Region.Framework.Scenes
936 List<ulong> old = new List<ulong>(); 957 List<ulong> old = new List<ulong>();
937 old.Add(otherRegion.RegionHandle); 958 old.Add(otherRegion.RegionHandle);
938 agent.DropOldNeighbours(old); 959 agent.DropOldNeighbours(old);
939 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 960 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
940 m_teleportModule.EnableChildAgent(agent, otherRegion); 961 EntityTransferModule.EnableChildAgent(agent, otherRegion);
941 }); 962 });
942 } 963 }
943 catch (NullReferenceException) 964 catch (NullReferenceException)
@@ -1044,13 +1065,13 @@ namespace OpenSim.Region.Framework.Scenes
1044 } 1065 }
1045 } 1066 }
1046 1067
1068 m_log.Error("[REGION]: Closing");
1069 Close();
1070
1047 if (PhysicsScene != null) 1071 if (PhysicsScene != null)
1048 { 1072 {
1049 PhysicsScene.Dispose(); 1073 PhysicsScene.Dispose();
1050 } 1074 }
1051
1052 m_log.Error("[REGION]: Closing");
1053 Close();
1054 1075
1055 m_log.Error("[REGION]: Firing Region Restart Message"); 1076 m_log.Error("[REGION]: Firing Region Restart Message");
1056 1077
@@ -1074,8 +1095,8 @@ namespace OpenSim.Region.Framework.Scenes
1074 { 1095 {
1075 ForEachRootScenePresence(delegate(ScenePresence agent) 1096 ForEachRootScenePresence(delegate(ScenePresence agent)
1076 { 1097 {
1077 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 1098 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
1078 m_teleportModule.EnableChildAgent(agent, r); 1099 EntityTransferModule.EnableChildAgent(agent, r);
1079 }); 1100 });
1080 } 1101 }
1081 catch (NullReferenceException) 1102 catch (NullReferenceException)
@@ -1265,7 +1286,7 @@ namespace OpenSim.Region.Framework.Scenes
1265 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1286 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1266 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1287 m_dialogModule = RequestModuleInterface<IDialogModule>();
1267 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1288 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1268 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1289 EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
1269 m_groupsModule = RequestModuleInterface<IGroupsModule>(); 1290 m_groupsModule = RequestModuleInterface<IGroupsModule>();
1270 } 1291 }
1271 1292
@@ -1404,6 +1425,14 @@ namespace OpenSim.Region.Framework.Scenes
1404 1425
1405 try 1426 try
1406 { 1427 {
1428 // Apply taints in terrain module to terrain in physics scene
1429 if (Frame % m_update_terrain == 0)
1430 {
1431 terMS = Util.EnvironmentTickCount();
1432 UpdateTerrain();
1433 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1434 }
1435
1407 tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1436 tmpPhysicsMS2 = Util.EnvironmentTickCount();
1408 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1437 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1409 m_sceneGraph.UpdatePreparePhysics(); 1438 m_sceneGraph.UpdatePreparePhysics();
@@ -1468,13 +1497,6 @@ namespace OpenSim.Region.Framework.Scenes
1468 backupMS = Util.EnvironmentTickCountSubtract(backMS); 1497 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1469 } 1498 }
1470 1499
1471 if (Frame % m_update_terrain == 0)
1472 {
1473 terMS = Util.EnvironmentTickCount();
1474 UpdateTerrain();
1475 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1476 }
1477
1478 //if (Frame % m_update_land == 0) 1500 //if (Frame % m_update_land == 0)
1479 //{ 1501 //{
1480 // int ldMS = Util.EnvironmentTickCount(); 1502 // int ldMS = Util.EnvironmentTickCount();
@@ -2363,8 +2385,8 @@ namespace OpenSim.Region.Framework.Scenes
2363 return; 2385 return;
2364 } 2386 }
2365 2387
2366 if (m_teleportModule != null) 2388 if (EntityTransferModule != null)
2367 m_teleportModule.Cross(grp, attemptedPosition, silent); 2389 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2368 } 2390 }
2369 2391
2370 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2392 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2684,10 +2706,10 @@ namespace OpenSim.Region.Framework.Scenes
2684 { 2706 {
2685 SceneObjectGroup grp = sceneObject; 2707 SceneObjectGroup grp = sceneObject;
2686 2708
2687 m_log.DebugFormat( 2709// m_log.DebugFormat(
2688 "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); 2710// "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
2689 m_log.DebugFormat( 2711// m_log.DebugFormat(
2690 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2712// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2691 2713
2692 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2714 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2693 2715
@@ -2783,7 +2805,8 @@ namespace OpenSim.Region.Framework.Scenes
2783 if (sp == null) 2805 if (sp == null)
2784 { 2806 {
2785 m_log.DebugFormat( 2807 m_log.DebugFormat(
2786 "[SCENE]: Adding new child scene presence {0} to scene {1} at pos {2}", client.Name, RegionInfo.RegionName, client.StartPos); 2808 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}",
2809 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos);
2787 2810
2788 m_clientManager.Add(client); 2811 m_clientManager.Add(client);
2789 SubscribeToClientEvents(client); 2812 SubscribeToClientEvents(client);
@@ -3207,8 +3230,10 @@ namespace OpenSim.Region.Framework.Scenes
3207 /// <param name="client">The IClientAPI for the client</param> 3230 /// <param name="client">The IClientAPI for the client</param>
3208 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) 3231 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3209 { 3232 {
3210 if (m_teleportModule != null) 3233 if (EntityTransferModule != null)
3211 return m_teleportModule.TeleportHome(agentId, client); 3234 {
3235 EntityTransferModule.TeleportHome(agentId, client);
3236 }
3212 else 3237 else
3213 { 3238 {
3214 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3239 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
@@ -3382,8 +3407,8 @@ namespace OpenSim.Region.Framework.Scenes
3382 try 3407 try
3383 { 3408 {
3384 m_log.DebugFormat( 3409 m_log.DebugFormat(
3385 "[SCENE]: Removing {0} agent {1} from region {2}", 3410 "[SCENE]: Removing {0} agent {1} {2} from region {3}",
3386 (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName); 3411 (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName);
3387 3412
3388 m_sceneGraph.removeUserCount(!isChildAgent); 3413 m_sceneGraph.removeUserCount(!isChildAgent);
3389 3414
@@ -3554,7 +3579,7 @@ namespace OpenSim.Region.Framework.Scenes
3554 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) 3579 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup)
3555 { 3580 {
3556 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || 3581 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 ||
3557 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); 3582 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0);
3558 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); 3583 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0);
3559 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); 3584 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
3560 3585
@@ -3570,8 +3595,17 @@ namespace OpenSim.Region.Framework.Scenes
3570 // Don't disable this log message - it's too helpful 3595 // Don't disable this log message - it's too helpful
3571 m_log.DebugFormat( 3596 m_log.DebugFormat(
3572 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})", 3597 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})",
3573 RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname, 3598 RegionInfo.RegionName,
3574 agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); 3599 (agent.child ? "child" : "root"),
3600 agent.firstname,
3601 agent.lastname,
3602 agent.AgentID,
3603 agent.circuitcode,
3604 agent.IPAddress,
3605 agent.Viewer,
3606 ((TPFlags)teleportFlags).ToString(),
3607 agent.startpos
3608 );
3575 3609
3576 if (LoginsDisabled) 3610 if (LoginsDisabled)
3577 { 3611 {
@@ -3586,7 +3620,11 @@ namespace OpenSim.Region.Framework.Scenes
3586 // We have a zombie from a crashed session. 3620 // We have a zombie from a crashed session.
3587 // Or the same user is trying to be root twice here, won't work. 3621 // Or the same user is trying to be root twice here, won't work.
3588 // Kill it. 3622 // Kill it.
3589 m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); 3623 m_log.DebugFormat(
3624 "[SCENE]: Zombie scene presence detected for {0} in {1}",
3625 agent.AgentID,
3626 RegionInfo.RegionName
3627 );
3590 sp.ControllingClient.Close(); 3628 sp.ControllingClient.Close();
3591 sp = null; 3629 sp = null;
3592 } 3630 }
@@ -3613,8 +3651,7 @@ namespace OpenSim.Region.Framework.Scenes
3613 { 3651 {
3614 if (!VerifyUserPresence(agent, out reason)) 3652 if (!VerifyUserPresence(agent, out reason))
3615 return false; 3653 return false;
3616 } 3654 } catch (Exception e)
3617 catch (Exception e)
3618 { 3655 {
3619 m_log.ErrorFormat( 3656 m_log.ErrorFormat(
3620 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3657 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
@@ -3649,8 +3686,7 @@ namespace OpenSim.Region.Framework.Scenes
3649 CapsModule.SetAgentCapsSeeds(agent); 3686 CapsModule.SetAgentCapsSeeds(agent);
3650 CapsModule.CreateCaps(agent.AgentID); 3687 CapsModule.CreateCaps(agent.AgentID);
3651 } 3688 }
3652 } 3689 } else
3653 else
3654 { 3690 {
3655 // Let the SP know how we got here. This has a lot of interesting 3691 // Let the SP know how we got here. This has a lot of interesting
3656 // uses down the line. 3692 // uses down the line.
@@ -3673,7 +3709,7 @@ namespace OpenSim.Region.Framework.Scenes
3673 agent.teleportFlags = teleportFlags; 3709 agent.teleportFlags = teleportFlags;
3674 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3710 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3675 3711
3676 if (vialogin) 3712 if (vialogin)
3677 { 3713 {
3678// CleanDroppedAttachments(); 3714// CleanDroppedAttachments();
3679 3715
@@ -3714,8 +3750,7 @@ namespace OpenSim.Region.Framework.Scenes
3714 agent.startpos.Z = 720; 3750 agent.startpos.Z = 720;
3715 } 3751 }
3716 } 3752 }
3717 } 3753 } else
3718 else
3719 { 3754 {
3720 if (agent.startpos.X > EastBorders[0].BorderLine.Z) 3755 if (agent.startpos.X > EastBorders[0].BorderLine.Z)
3721 { 3756 {
@@ -3741,10 +3776,19 @@ namespace OpenSim.Region.Framework.Scenes
3741 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); 3776 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3742 // Can have multiple SpawnPoints 3777 // Can have multiple SpawnPoints
3743 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); 3778 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
3744 if ( spawnpoints.Count > 1) 3779 if (spawnpoints.Count > 1)
3745 { 3780 {
3746 // We have multiple SpawnPoints, Route the agent to a random one 3781 // We have multiple SpawnPoints, Route the agent to a random or sequential one
3747 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count)].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 3782 if (SpawnPointRouting == "random")
3783 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
3784 telehub.AbsolutePosition,
3785 telehub.GroupRotation
3786 );
3787 else
3788 agent.startpos = spawnpoints[SpawnPoint()].GetLocation(
3789 telehub.AbsolutePosition,
3790 telehub.GroupRotation
3791 );
3748 } 3792 }
3749 else 3793 else
3750 { 3794 {
@@ -3981,41 +4025,41 @@ namespace OpenSim.Region.Framework.Scenes
3981 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); 4025 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
3982 } 4026 }
3983 4027
3984 /// <summary> 4028// /// <summary>
3985 /// The Grid has requested that we log-off a user. Log them off. 4029// /// The Grid has requested that we log-off a user. Log them off.
3986 /// </summary> 4030// /// </summary>
3987 /// <param name="AvatarID">Unique ID of the avatar to log-off</param> 4031// /// <param name="AvatarID">Unique ID of the avatar to log-off</param>
3988 /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> 4032// /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param>
3989 /// <param name="message">message to display to the user. Reason for being logged off</param> 4033// /// <param name="message">message to display to the user. Reason for being logged off</param>
3990 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) 4034// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3991 { 4035// {
3992 ScenePresence loggingOffUser = GetScenePresence(AvatarID); 4036// ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3993 if (loggingOffUser != null) 4037// if (loggingOffUser != null)
3994 { 4038// {
3995 UUID localRegionSecret = UUID.Zero; 4039// UUID localRegionSecret = UUID.Zero;
3996 bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); 4040// bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret);
3997 4041//
3998 // Region Secret is used here in case a new sessionid overwrites an old one on the user server. 4042// // Region Secret is used here in case a new sessionid overwrites an old one on the user server.
3999 // Will update the user server in a few revisions to use it. 4043// // Will update the user server in a few revisions to use it.
4000 4044//
4001 if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) 4045// if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret))
4002 { 4046// {
4003 m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); 4047// m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles);
4004 loggingOffUser.ControllingClient.Kick(message); 4048// loggingOffUser.ControllingClient.Kick(message);
4005 // Give them a second to receive the message! 4049// // Give them a second to receive the message!
4006 Thread.Sleep(1000); 4050// Thread.Sleep(1000);
4007 loggingOffUser.ControllingClient.Close(); 4051// loggingOffUser.ControllingClient.Close();
4008 } 4052// }
4009 else 4053// else
4010 { 4054// {
4011 m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); 4055// m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
4012 } 4056// }
4013 } 4057// }
4014 else 4058// else
4015 { 4059// {
4016 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()); 4060// 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());
4017 } 4061// }
4018 } 4062// }
4019 4063
4020 /// <summary> 4064 /// <summary>
4021 /// Triggered when an agent crosses into this sim. Also happens on initial login. 4065 /// Triggered when an agent crosses into this sim. Also happens on initial login.
@@ -4068,21 +4112,19 @@ namespace OpenSim.Region.Framework.Scenes
4068 return false; 4112 return false;
4069 } 4113 }
4070 4114
4115 // TODO: This check should probably be in QueryAccess().
4071 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4116 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4072 if (nearestParcel == null) 4117 if (nearestParcel == null)
4073 { 4118 {
4074 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); 4119 m_log.DebugFormat(
4075 return false; 4120 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
4076 } 4121 cAgentData.AgentID, RegionInfo.RegionName);
4077
4078 int num = m_sceneGraph.GetNumberOfScenePresences();
4079 4122
4080 if (num >= RegionInfo.RegionSettings.AgentLimit) 4123 return false;
4081 {
4082 if (!Permissions.IsAdministrator(cAgentData.AgentID))
4083 return false;
4084 } 4124 }
4085 4125
4126 // We have to wait until the viewer contacts this region after receiving EAC.
4127 // That calls AddNewClient, which finally creates the ScenePresence
4086 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 4128 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
4087 4129
4088 if (childAgentUpdate != null) 4130 if (childAgentUpdate != null)
@@ -4126,14 +4168,28 @@ namespace OpenSim.Region.Framework.Scenes
4126 return false; 4168 return false;
4127 } 4169 }
4128 4170
4171 /// <summary>
4172 /// Poll until the requested ScenePresence appears or we timeout.
4173 /// </summary>
4174 /// <returns>The scene presence is found, else null.</returns>
4175 /// <param name='agentID'></param>
4129 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4176 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4130 { 4177 {
4131 int ntimes = 10; 4178 int ntimes = 10;
4132 ScenePresence childAgentUpdate = null; 4179 ScenePresence sp = null;
4133 while ((childAgentUpdate = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4180 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4134 Thread.Sleep(1000); 4181 Thread.Sleep(1000);
4135 return childAgentUpdate;
4136 4182
4183 if (sp == null)
4184 m_log.WarnFormat(
4185 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
4186 agentID, RegionInfo.RegionName);
4187// else
4188// m_log.DebugFormat(
4189// "[SCENE PRESENCE]: Found presence {0} {1} {2} in {3} after {4} waits",
4190// sp.Name, sp.UUID, sp.IsChildAgent ? "child" : "root", RegionInfo.RegionName, 10 - ntimes);
4191
4192 return sp;
4137 } 4193 }
4138 4194
4139 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) 4195 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent)
@@ -4283,8 +4339,10 @@ namespace OpenSim.Region.Framework.Scenes
4283 position.Y -= shifty; 4339 position.Y -= shifty;
4284 } 4340 }
4285 4341
4286 if (m_teleportModule != null) 4342 if (EntityTransferModule != null)
4287 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4343 {
4344 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4345 }
4288 else 4346 else
4289 { 4347 {
4290 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); 4348 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
@@ -4295,8 +4353,10 @@ namespace OpenSim.Region.Framework.Scenes
4295 4353
4296 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 4354 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4297 { 4355 {
4298 if (m_teleportModule != null) 4356 if (EntityTransferModule != null)
4299 return m_teleportModule.Cross(agent, isFlying); 4357 {
4358 return EntityTransferModule.Cross(agent, isFlying);
4359 }
4300 else 4360 else
4301 { 4361 {
4302 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 4362 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
@@ -5444,29 +5504,58 @@ Environment.Exit(1);
5444 throw new Exception(error); 5504 throw new Exception(error);
5445 } 5505 }
5446 5506
5447 // This method is called across the simulation connector to 5507 /// <summary>
5448 // determine if a given agent is allowed in this region 5508 /// This method is called across the simulation connector to
5449 // AS A ROOT AGENT. Returning false here will prevent them 5509 /// determine if a given agent is allowed in this region
5450 // from logging into the region, teleporting into the region 5510 /// AS A ROOT AGENT
5451 // or corssing the broder walking, but will NOT prevent 5511 /// </summary>
5452 // child agent creation, thereby emulating the SL behavior. 5512 /// <remarks>
5513 /// Returning false here will prevent them
5514 /// from logging into the region, teleporting into the region
5515 /// or corssing the broder walking, but will NOT prevent
5516 /// child agent creation, thereby emulating the SL behavior.
5517 /// </remarks>
5518 /// <param name='agentID'></param>
5519 /// <param name='position'></param>
5520 /// <param name='reason'></param>
5521 /// <returns></returns>
5453 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5522 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5454 { 5523 {
5455 reason = "You are banned from the region"; 5524 reason = "You are banned from the region";
5456 5525
5526 if (EntityTransferModule.IsInTransit(agentID))
5527 {
5528 reason = "Agent is still in transit from this region";
5529
5530 m_log.WarnFormat(
5531 "[SCENE]: Denying agent {0} entry into {1} since region still has them registered as in transit",
5532 agentID, RegionInfo.RegionName);
5533
5534 return false;
5535 }
5536
5457 if (Permissions.IsGod(agentID)) 5537 if (Permissions.IsGod(agentID))
5458 { 5538 {
5459 reason = String.Empty; 5539 reason = String.Empty;
5460 return true; 5540 return true;
5461 } 5541 }
5462 5542
5463 int num = m_sceneGraph.GetNumberOfScenePresences(); 5543 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5544 // However, the long term fix is to make sure root agent count is always accurate.
5545 m_sceneGraph.RecalculateStats();
5546
5547 int num = m_sceneGraph.GetRootAgentCount();
5464 5548
5465 if (num >= RegionInfo.RegionSettings.AgentLimit) 5549 if (num >= RegionInfo.RegionSettings.AgentLimit)
5466 { 5550 {
5467 if (!Permissions.IsAdministrator(agentID)) 5551 if (!Permissions.IsAdministrator(agentID))
5468 { 5552 {
5469 reason = "The region is full"; 5553 reason = "The region is full";
5554
5555 m_log.DebugFormat(
5556 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}",
5557 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit);
5558
5470 return false; 5559 return false;
5471 } 5560 }
5472 } 5561 }
@@ -5637,5 +5726,19 @@ Environment.Exit(1);
5637 } 5726 }
5638 } 5727 }
5639 } 5728 }
5729
5730 // manage and select spawn points in sequence
5731 public int SpawnPoint()
5732 {
5733 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
5734
5735 if (spawnpoints == 0)
5736 return 0;
5737
5738 m_SpawnPoint++;
5739 if (m_SpawnPoint > spawnpoints)
5740 m_SpawnPoint = 1;
5741 return m_SpawnPoint - 1;
5742 }
5640 } 5743 }
5641} 5744}