aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs11
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScenePresence.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs50
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs69
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs129
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs36
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs60
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs27
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs302
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs2
16 files changed, 472 insertions, 236 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
index aa4a757..136ca92 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
@@ -25,14 +25,23 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28
29using System; 28using System;
29using OpenSim.Framework;
30 30
31namespace OpenSim.Region.Framework.Interfaces 31namespace OpenSim.Region.Framework.Interfaces
32{ 32{
33 public interface IRegionReadyModule 33 public interface IRegionReadyModule
34 { 34 {
35 void OarLoadingAlert(string msg); 35 void OarLoadingAlert(string msg);
36
37 /// <summary>
38 /// Trigger region ready status manually.
39 /// </summary>
40 /// <remarks>
41 /// This should be called by the scene if the IRegionReadyModule has set Scene.LoginLock == true
42 /// </remarks>
43 /// <param name='scene'></param>
44 void TriggerRegionReady(IScene scene);
36 } 45 }
37} 46}
38 47
diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
index 3f68ee0..0fe681f 100644
--- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
@@ -40,8 +40,6 @@ namespace OpenSim.Region.Framework.Interfaces
40 /// </remarks> 40 /// </remarks>
41 public interface IScenePresence : ISceneAgent 41 public interface IScenePresence : ISceneAgent
42 { 42 {
43 PresenceType PresenceType { get; }
44
45 /// <summary> 43 /// <summary>
46 /// Copy of the script states while the agent is in transit. This state may 44 /// Copy of the script states while the agent is in transit. This state may
47 /// need to be placed back in case of transfer fail. 45 /// need to be placed back in case of transfer fail.
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
index bfe1e8d..ed71a95 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
@@ -67,6 +67,10 @@ namespace OpenSim.Region.Framework.Interfaces
67 /// <param name="key"></param> 67 /// <param name="key"></param>
68 void DispatchReply(UUID scriptId, int code, string text, string key); 68 void DispatchReply(UUID scriptId, int code, string text, string key);
69 69
70 /// For constants
71 void RegisterConstant(string cname, object value);
72 object LookupModConstant(string cname);
73
70 // For use ONLY by the script API 74 // For use ONLY by the script API
71 void RaiseEvent(UUID script, string id, string module, string command, string key); 75 void RaiseEvent(UUID script, string id, string module, string command, string key);
72 } 76 }
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 9ddac19..50a176b 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -551,11 +551,5 @@ namespace OpenSim.Region.Framework.Scenes.Animation
551 551
552 SendAnimPack(animIDs, sequenceNums, objectIDs); 552 SendAnimPack(animIDs, sequenceNums, objectIDs);
553 } 553 }
554
555 public void Close()
556 {
557 m_animations = null;
558 m_scenePresence = null;
559 }
560 } 554 }
561} 555} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index d783e57..7cb3811 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -500,15 +500,24 @@ namespace OpenSim.Region.Framework.Scenes
500 public delegate void RegionHeartbeatEnd(Scene scene); 500 public delegate void RegionHeartbeatEnd(Scene scene);
501 public event RegionHeartbeatEnd OnRegionHeartbeatEnd; 501 public event RegionHeartbeatEnd OnRegionHeartbeatEnd;
502 502
503 public delegate void LoginsEnabled(string regionName); 503 /// <summary>
504 /// Fired when logins to a region are enabled or disabled.
505 /// </summary>
506 /// <remarks>
507 ///
508 /// </remarks>
509 /// Fired
510 public event RegionLoginsStatusChange OnRegionLoginsStatusChange;
511 public delegate void RegionLoginsStatusChange(IScene scene);
504 512
505 /// <summary> 513 /// <summary>
506 /// This should only fire in all circumstances if the RegionReady module is active. 514 /// Fired when a region is considered ready for use.
507 /// </summary> 515 /// </summary>
508 /// <remarks> 516 /// <remarks>
509 /// TODO: Fire this even when the RegionReady module is not active. 517 /// A region is considered ready when startup operations such as loading of scripts already on the region
518 /// have been completed.
510 /// </remarks> 519 /// </remarks>
511 public event LoginsEnabled OnLoginsEnabled; 520 public event Action<IScene> OnRegionReadyStatusChange;
512 521
513 public delegate void PrimsLoaded(Scene s); 522 public delegate void PrimsLoaded(Scene s);
514 public event PrimsLoaded OnPrimsLoaded; 523 public event PrimsLoaded OnPrimsLoaded;
@@ -2502,21 +2511,42 @@ namespace OpenSim.Region.Framework.Scenes
2502 } 2511 }
2503 } 2512 }
2504 2513
2505 public void TriggerLoginsEnabled (string regionName) 2514 public void TriggerRegionLoginsStatusChange(IScene scene)
2506 { 2515 {
2507 LoginsEnabled handler = OnLoginsEnabled; 2516 RegionLoginsStatusChange handler = OnRegionLoginsStatusChange;
2508 2517
2509 if ( handler != null) 2518 if (handler != null)
2510 { 2519 {
2511 foreach (LoginsEnabled d in handler.GetInvocationList()) 2520 foreach (RegionLoginsStatusChange d in handler.GetInvocationList())
2512 { 2521 {
2513 try 2522 try
2514 { 2523 {
2515 d(regionName); 2524 d(scene);
2525 }
2526 catch (Exception e)
2527 {
2528 m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionLoginsStatusChange failed - continuing {0} - {1}",
2529 e.Message, e.StackTrace);
2530 }
2531 }
2532 }
2533 }
2534
2535 public void TriggerRegionReadyStatusChange(IScene scene)
2536 {
2537 Action<IScene> handler = OnRegionReadyStatusChange;
2538
2539 if (handler != null)
2540 {
2541 foreach (Action<IScene> d in handler.GetInvocationList())
2542 {
2543 try
2544 {
2545 d(scene);
2516 } 2546 }
2517 catch (Exception e) 2547 catch (Exception e)
2518 { 2548 {
2519 m_log.ErrorFormat("[EVENT MANAGER]: Delegate for LoginsEnabled failed - continuing {0} - {1}", 2549 m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReadyStatusChange failed - continuing {0} - {1}",
2520 e.Message, e.StackTrace); 2550 e.Message, e.StackTrace);
2521 } 2551 }
2522 } 2552 }
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index 1365831..c11174d 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -39,7 +39,7 @@ using OpenSim.Framework.Communications;
39using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer; 41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics; 42using OpenSim.Framework.Monitoring;
43using OpenSim.Region.Framework; 43using OpenSim.Region.Framework;
44using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 98b8fcc..672d95a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -811,16 +811,20 @@ namespace OpenSim.Region.Framework.Scenes
811 && oldAgentID == LibraryService.LibraryRootFolder.Owner)) 811 && oldAgentID == LibraryService.LibraryRootFolder.Owner))
812 { 812 {
813 CreateNewInventoryItem( 813 CreateNewInventoryItem(
814 remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType, 814 remoteClient, item.CreatorId, item.CreatorData, newFolderID,
815 item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); 815 newName, item.Description, item.Flags, callbackID, asset, (sbyte)item.InvType,
816 item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions,
817 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
816 } 818 }
817 else 819 else
818 { 820 {
819 // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. 821 // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item.
820 if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) && (m_permissions.BypassPermissions() || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) 822 if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0)
823 && (m_permissions.BypassPermissions()
824 || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID)))
821 { 825 {
822 CreateNewInventoryItem( 826 CreateNewInventoryItem(
823 remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Flags, callbackID, 827 remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID,
824 asset, (sbyte) item.InvType, 828 asset, (sbyte) item.InvType,
825 item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, 829 item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions,
826 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); 830 item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch());
@@ -885,32 +889,50 @@ namespace OpenSim.Region.Framework.Scenes
885 /// <summary> 889 /// <summary>
886 /// Create a new inventory item. 890 /// Create a new inventory item.
887 /// </summary> 891 /// </summary>
888 /// <param name="remoteClient"></param> 892 /// <param name="remoteClient">Client creating this inventory item.</param>
889 /// <param name="folderID"></param> 893 /// <param name="creatorID"></param>
890 /// <param name="callbackID"></param> 894 /// <param name="creatorData"></param>
891 /// <param name="asset"></param> 895 /// <param name="folderID">UUID of folder in which this item should be placed.</param>
892 /// <param name="invType"></param> 896 /// <param name="name">Item name.</para>
893 /// <param name="nextOwnerMask"></param> 897 /// <param name="description">Item description.</param>
894 public void CreateNewInventoryItem(IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID, 898 /// <param name="flags">Item flags</param>
895 AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) 899 /// <param name="callbackID">Generated by the client.</para>
900 /// <param name="asset">Asset to which this item refers.</param>
901 /// <param name="invType">Type of inventory item.</param>
902 /// <param name="nextOwnerMask">Next owner pemrissions mask.</param>
903 /// <param name="creationDate">Unix timestamp at which this item was created.</param>
904 public void CreateNewInventoryItem(
905 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
906 string name, string description, uint flags, uint callbackID,
907 AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate)
896 { 908 {
897 CreateNewInventoryItem( 909 CreateNewInventoryItem(
898 remoteClient, creatorID, creatorData, folderID, name, flags, callbackID, asset, invType, 910 remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType,
899 (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); 911 (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate);
900 } 912 }
901 913
902 /// <summary> 914 /// <summary>
903 /// Create a new Inventory Item 915 /// Create a new Inventory Item
904 /// </summary> 916 /// </summary>
905 /// <param name="remoteClient"></param> 917 /// <param name="remoteClient">Client creating this inventory item.</param>
906 /// <param name="folderID"></param> 918 /// <param name="creatorID"></param>
907 /// <param name="callbackID"></param> 919 /// <param name="creatorData"></param>
908 /// <param name="asset"></param> 920 /// <param name="folderID">UUID of folder in which this item should be placed.</param>
909 /// <param name="invType"></param> 921 /// <param name="name">Item name.</para>
910 /// <param name="nextOwnerMask"></param> 922 /// <param name="description">Item description.</param>
911 /// <param name="creationDate"></param> 923 /// <param name="flags">Item flags</param>
924 /// <param name="callbackID">Generated by the client.</para>
925 /// <param name="asset">Asset to which this item refers.</param>
926 /// <param name="invType">Type of inventory item.</param>
927 /// <param name="baseMask">Base permissions mask.</param>
928 /// <param name="currentMask">Current permissions mask.</param>
929 /// <param name="everyoneMask">Everyone permissions mask.</param>
930 /// <param name="nextOwnerMask">Next owner pemrissions mask.</param>
931 /// <param name="groupMask">Group permissions mask.</param>
932 /// <param name="creationDate">Unix timestamp at which this item was created.</param>
912 private void CreateNewInventoryItem( 933 private void CreateNewInventoryItem(
913 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID, AssetBase asset, sbyte invType, 934 IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID,
935 string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType,
914 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) 936 uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate)
915 { 937 {
916 InventoryItemBase item = new InventoryItemBase(); 938 InventoryItemBase item = new InventoryItemBase();
@@ -919,8 +941,8 @@ namespace OpenSim.Region.Framework.Scenes
919 item.CreatorData = creatorData; 941 item.CreatorData = creatorData;
920 item.ID = UUID.Random(); 942 item.ID = UUID.Random();
921 item.AssetID = asset.FullID; 943 item.AssetID = asset.FullID;
922 item.Description = asset.Description;
923 item.Name = name; 944 item.Name = name;
945 item.Description = description;
924 item.Flags = flags; 946 item.Flags = flags;
925 item.AssetType = asset.Type; 947 item.AssetType = asset.Type;
926 item.InvType = invType; 948 item.InvType = invType;
@@ -1002,7 +1024,8 @@ namespace OpenSim.Region.Framework.Scenes
1002 asset.Description = description; 1024 asset.Description = description;
1003 1025
1004 CreateNewInventoryItem( 1026 CreateNewInventoryItem(
1005 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType, 1027 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
1028 name, description, 0, callbackID, asset, invType,
1006 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, 1029 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All,
1007 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); 1030 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch());
1008 } 1031 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ad9e91d..3a28d42 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -40,6 +40,7 @@ using OpenMetaverse;
40using OpenMetaverse.Packets; 40using OpenMetaverse.Packets;
41using OpenMetaverse.Imaging; 41using OpenMetaverse.Imaging;
42using OpenSim.Framework; 42using OpenSim.Framework;
43using OpenSim.Framework.Monitoring;
43using OpenSim.Services.Interfaces; 44using OpenSim.Services.Interfaces;
44using OpenSim.Framework.Communications; 45using OpenSim.Framework.Communications;
45using OpenSim.Framework.Console; 46using OpenSim.Framework.Console;
@@ -129,9 +130,10 @@ namespace OpenSim.Region.Framework.Scenes
129 public bool m_strictAccessControl = true; 130 public bool m_strictAccessControl = true;
130 public bool m_seeIntoBannedRegion = false; 131 public bool m_seeIntoBannedRegion = false;
131 public int MaxUndoCount = 5; 132 public int MaxUndoCount = 5;
133
132 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 134 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
133 public bool LoginLock = false; 135 public bool LoginLock = false;
134 public bool LoginsDisabled = true; 136
135 public bool StartDisabled = false; 137 public bool StartDisabled = false;
136 public bool LoadingPrims; 138 public bool LoadingPrims;
137 public IXfer XferManager; 139 public IXfer XferManager;
@@ -727,6 +729,8 @@ namespace OpenSim.Region.Framework.Scenes
727 { 729 {
728 IConfig startupConfig = m_config.Configs["Startup"]; 730 IConfig startupConfig = m_config.Configs["Startup"];
729 731
732 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
733
730 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); 734 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
731 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); 735 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
732 if (!m_useBackup) 736 if (!m_useBackup)
@@ -1229,15 +1233,17 @@ namespace OpenSim.Region.Framework.Scenes
1229 avatar.ControllingClient.SendShutdownConnectionNotice(); 1233 avatar.ControllingClient.SendShutdownConnectionNotice();
1230 }); 1234 });
1231 1235
1236 // Stop updating the scene objects and agents.
1237 m_shuttingDown = true;
1238
1232 // Wait here, or the kick messages won't actually get to the agents before the scene terminates. 1239 // Wait here, or the kick messages won't actually get to the agents before the scene terminates.
1240 // We also need to wait to avoid a race condition with the scene update loop which might not yet
1241 // have checked ShuttingDown.
1233 Thread.Sleep(500); 1242 Thread.Sleep(500);
1234 1243
1235 // Stop all client threads. 1244 // Stop all client threads.
1236 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); 1245 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); });
1237 1246
1238 // Stop updating the scene objects and agents.
1239 m_shuttingDown = true;
1240
1241 m_log.Debug("[SCENE]: Persisting changed objects"); 1247 m_log.Debug("[SCENE]: Persisting changed objects");
1242 EventManager.TriggerSceneShuttingDown(this); 1248 EventManager.TriggerSceneShuttingDown(this);
1243 1249
@@ -1252,6 +1258,15 @@ namespace OpenSim.Region.Framework.Scenes
1252 1258
1253 m_sceneGraph.Close(); 1259 m_sceneGraph.Close();
1254 1260
1261 if (PhysicsScene != null)
1262 {
1263 PhysicsScene phys = PhysicsScene;
1264 // remove the physics engine from both Scene and SceneGraph
1265 PhysicsScene = null;
1266 phys.Dispose();
1267 phys = null;
1268 }
1269
1255 if (!GridService.DeregisterRegion(RegionInfo.RegionID)) 1270 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
1256 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); 1271 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
1257 1272
@@ -1530,7 +1545,7 @@ namespace OpenSim.Region.Framework.Scenes
1530 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1545 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1531 //} 1546 //}
1532 1547
1533 if (LoginsDisabled && Frame == 20) 1548 if (!LoginsEnabled && Frame == 20)
1534 { 1549 {
1535 // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); 1550 // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock);
1536 1551
@@ -1538,31 +1553,34 @@ namespace OpenSim.Region.Framework.Scenes
1538 // this is a rare case where we know we have just went through a long cycle of heap 1553 // this is a rare case where we know we have just went through a long cycle of heap
1539 // allocations, and there is no more work to be done until someone logs in 1554 // allocations, and there is no more work to be done until someone logs in
1540 GC.Collect(); 1555 GC.Collect();
1541 1556
1542 IConfig startupConfig = m_config.Configs["Startup"]; 1557 if (!LoginLock)
1543 if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
1544 { 1558 {
1545 // This handles a case of a region having no scripts for the RegionReady module 1559 if (!StartDisabled)
1546 if (m_sceneGraph.GetActiveScriptsCount() == 0)
1547 {
1548 // need to be able to tell these have changed in RegionReady
1549 LoginLock = false;
1550 EventManager.TriggerLoginsEnabled(RegionInfo.RegionName);
1551 }
1552
1553 // For RegionReady lockouts
1554 if (!LoginLock)
1555 { 1560 {
1556 m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); 1561 m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1557 LoginsDisabled = false; 1562 LoginsEnabled = true;
1558 } 1563 }
1559 1564
1560 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1565 m_sceneGridService.InformNeighborsThatRegionisUp(
1566 RequestModuleInterface<INeighbourService>(), RegionInfo);
1567
1568 // Region ready should always be set
1569 Ready = true;
1561 } 1570 }
1562 else 1571 else
1563 { 1572 {
1564 StartDisabled = true; 1573 // This handles a case of a region having no scripts for the RegionReady module
1565 LoginsDisabled = true; 1574 if (m_sceneGraph.GetActiveScriptsCount() == 0)
1575 {
1576 // In this case, we leave it to the IRegionReadyModule to enable logins
1577
1578 // LoginLock can currently only be set by a region module implementation.
1579 // If somehow this hasn't been done then the quickest way to bugfix is to see the
1580 // NullReferenceException
1581 IRegionReadyModule rrm = RequestModuleInterface<IRegionReadyModule>();
1582 rrm.TriggerRegionReady(this);
1583 }
1566 } 1584 }
1567 } 1585 }
1568 } 1586 }
@@ -3477,25 +3495,31 @@ namespace OpenSim.Region.Framework.Scenes
3477 if (AgentTransactionsModule != null) 3495 if (AgentTransactionsModule != null)
3478 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3496 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3479 3497
3480 avatar.Close();
3481
3482 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3498 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3483 m_log.Debug("[Scene] The avatar has left the building"); 3499 m_log.Debug("[Scene] The avatar has left the building");
3484 } 3500 }
3485 catch (Exception e) 3501 catch (Exception e)
3486 { 3502 {
3487 m_log.Error( 3503 m_log.Error(
3488 string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e); 3504 string.Format("[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e);
3489 } 3505 }
3490 finally 3506 finally
3491 { 3507 {
3492 // Always clean these structures up so that any failure above doesn't cause them to remain in the 3508 try
3493 // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering 3509 {
3494 // the same cleanup exception continually. 3510 // Always clean these structures up so that any failure above doesn't cause them to remain in the
3495 // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE 3511 // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
3496 // since this would hide the underlying failure and other associated problems. 3512 // the same cleanup exception continually.
3497 m_sceneGraph.RemoveScenePresence(agentID); 3513 m_sceneGraph.RemoveScenePresence(agentID);
3498 m_clientManager.Remove(agentID); 3514 m_clientManager.Remove(agentID);
3515
3516 avatar.Close();
3517 }
3518 catch (Exception e)
3519 {
3520 m_log.Error(
3521 string.Format("[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e);
3522 }
3499 } 3523 }
3500 3524
3501 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3525 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3609,7 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes
3609 agent.startpos 3633 agent.startpos
3610 ); 3634 );
3611 3635
3612 if (LoginsDisabled) 3636 if (!LoginsEnabled)
3613 { 3637 {
3614 reason = "Logins Disabled"; 3638 reason = "Logins Disabled";
3615 return false; 3639 return false;
@@ -3666,8 +3690,8 @@ namespace OpenSim.Region.Framework.Scenes
3666 // We have a zombie from a crashed session. 3690 // We have a zombie from a crashed session.
3667 // Or the same user is trying to be root twice here, won't work. 3691 // Or the same user is trying to be root twice here, won't work.
3668 // Kill it. 3692 // Kill it.
3669 m_log.DebugFormat( 3693 m_log.WarnFormat(
3670 "[SCENE]: Zombie scene presence detected for {0} {1} in {2}", 3694 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3671 sp.Name, sp.UUID, RegionInfo.RegionName); 3695 sp.Name, sp.UUID, RegionInfo.RegionName);
3672 3696
3673 sp.ControllingClient.Close(); 3697 sp.ControllingClient.Close();
@@ -4658,6 +4682,23 @@ namespace OpenSim.Region.Framework.Scenes
4658 } 4682 }
4659 4683
4660 /// <summary> 4684 /// <summary>
4685 /// Gets all the scene presences in this scene.
4686 /// </summary>
4687 /// <remarks>
4688 /// This method will return both root and child scene presences.
4689 ///
4690 /// Consider using ForEachScenePresence() or ForEachRootScenePresence() if possible since these will not
4691 /// involving creating a new List object.
4692 /// </remarks>
4693 /// <returns>
4694 /// A list of the scene presences. Adding or removing from the list will not affect the presences in the scene.
4695 /// </returns>
4696 public List<ScenePresence> GetScenePresences()
4697 {
4698 return new List<ScenePresence>(m_sceneGraph.GetScenePresences());
4699 }
4700
4701 /// <summary>
4661 /// Performs action on all avatars in the scene (root scene presences) 4702 /// Performs action on all avatars in the scene (root scene presences)
4662 /// Avatars may be an NPC or a 'real' client. 4703 /// Avatars may be an NPC or a 'real' client.
4663 /// </summary> 4704 /// </summary>
@@ -5775,5 +5816,21 @@ Environment.Exit(1);
5775 { 5816 {
5776 GC.Collect(); 5817 GC.Collect();
5777 } 5818 }
5819
5820 // Wrappers to get physics modules retrieve assets. Has to be done this way
5821 // because we can't assign the asset service to physics directly - at the
5822 // time physics are instantiated it's not registered but it will be by
5823 // the time the first prim exists.
5824 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback)
5825 {
5826 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived);
5827 }
5828
5829 private void PhysicsAssetReceived(string id, Object sender, AssetBase asset)
5830 {
5831 AssetReceivedDelegate callback = (AssetReceivedDelegate)sender;
5832
5833 callback(asset);
5834 }
5778 } 5835 }
5779} 5836}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 8db4397..7c8bd88 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -106,6 +106,42 @@ namespace OpenSim.Region.Framework.Scenes
106 106
107 protected readonly ClientManager m_clientManager = new ClientManager(); 107 protected readonly ClientManager m_clientManager = new ClientManager();
108 108
109 public bool LoginsEnabled
110 {
111 get
112 {
113 return m_loginsEnabled;
114 }
115
116 set
117 {
118 if (m_loginsEnabled != value)
119 {
120 m_loginsEnabled = value;
121 EventManager.TriggerRegionLoginsStatusChange(this);
122 }
123 }
124 }
125 private bool m_loginsEnabled;
126
127 public bool Ready
128 {
129 get
130 {
131 return m_ready;
132 }
133
134 set
135 {
136 if (m_ready != value)
137 {
138 m_ready = value;
139 EventManager.TriggerRegionReadyStatusChange(this);
140 }
141 }
142 }
143 private bool m_ready;
144
109 public float TimeDilation 145 public float TimeDilation
110 { 146 {
111 get { return 1.0f; } 147 get { return 1.0f; }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index c3d66eb..e0260e2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -848,7 +848,7 @@ namespace OpenSim.Region.Framework.Scenes
848 /// pass a delegate to ForEachScenePresence. 848 /// pass a delegate to ForEachScenePresence.
849 /// </summary> 849 /// </summary>
850 /// <returns></returns> 850 /// <returns></returns>
851 private List<ScenePresence> GetScenePresences() 851 protected internal List<ScenePresence> GetScenePresences()
852 { 852 {
853 return m_scenePresenceArray; 853 return m_scenePresenceArray;
854 } 854 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index e3fed49..f1b09ca 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -47,6 +47,48 @@ namespace OpenSim.Region.Framework.Scenes
47 47
48 public event RestartSim OnRestartSim; 48 public event RestartSim OnRestartSim;
49 49
50 /// <summary>
51 /// Fired when either all regions are ready for use or at least one region has become unready for use where
52 /// previously all regions were ready.
53 /// </summary>
54 public event Action<SceneManager> OnRegionsReadyStatusChange;
55
56 /// <summary>
57 /// Are all regions ready for use?
58 /// </summary>
59 public bool AllRegionsReady
60 {
61 get
62 {
63 return m_allRegionsReady;
64 }
65
66 private set
67 {
68 if (m_allRegionsReady != value)
69 {
70 m_allRegionsReady = value;
71 Action<SceneManager> handler = OnRegionsReadyStatusChange;
72 if (handler != null)
73 {
74 foreach (Action<SceneManager> d in handler.GetInvocationList())
75 {
76 try
77 {
78 d(this);
79 }
80 catch (Exception e)
81 {
82 m_log.ErrorFormat("[SCENE MANAGER]: Delegate for OnRegionsReadyStatusChange failed - continuing {0} - {1}",
83 e.Message, e.StackTrace);
84 }
85 }
86 }
87 }
88 }
89 }
90 private bool m_allRegionsReady;
91
50 private static SceneManager m_instance = null; 92 private static SceneManager m_instance = null;
51 public static SceneManager Instance 93 public static SceneManager Instance
52 { 94 {
@@ -128,9 +170,11 @@ namespace OpenSim.Region.Framework.Scenes
128 170
129 public void Add(Scene scene) 171 public void Add(Scene scene)
130 { 172 {
131 scene.OnRestart += HandleRestart; 173 lock (m_localScenes)
174 m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene);
132 175
133 m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); 176 scene.OnRestart += HandleRestart;
177 scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange;
134 } 178 }
135 179
136 public void HandleRestart(RegionInfo rdata) 180 public void HandleRestart(RegionInfo rdata)
@@ -138,12 +182,19 @@ namespace OpenSim.Region.Framework.Scenes
138 m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); 182 m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main");
139 int RegionSceneElement = -1; 183 int RegionSceneElement = -1;
140 184
141 m_localScenes.Remove(rdata.RegionID); 185 lock (m_localScenes)
186 m_localScenes.Remove(rdata.RegionID);
142 187
143 // Send signal to main that we're restarting this sim. 188 // Send signal to main that we're restarting this sim.
144 OnRestartSim(rdata); 189 OnRestartSim(rdata);
145 } 190 }
146 191
192 private void HandleRegionReadyStatusChange(IScene scene)
193 {
194 lock (m_localScenes)
195 AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0;
196 }
197
147 public void SendSimOnlineNotification(ulong regionHandle) 198 public void SendSimOnlineNotification(ulong regionHandle)
148 { 199 {
149 RegionInfo Result = null; 200 RegionInfo Result = null;
@@ -483,7 +534,8 @@ namespace OpenSim.Region.Framework.Scenes
483 534
484 public void CloseScene(Scene scene) 535 public void CloseScene(Scene scene)
485 { 536 {
486 m_localScenes.Remove(scene.RegionInfo.RegionID); 537 lock (m_localScenes)
538 m_localScenes.Remove(scene.RegionInfo.RegionID);
487 539
488 scene.Close(); 540 scene.Close();
489 } 541 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 6ab0027..08c7a58 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1991,7 +1991,7 @@ namespace OpenSim.Region.Framework.Scenes
1991 try 1991 try
1992 { 1992 {
1993 if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart 1993 if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart
1994 m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things 1994 !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things
1995 m_scene.LoadingPrims) // Land may not be valid yet 1995 m_scene.LoadingPrims) // Land may not be valid yet
1996 1996
1997 { 1997 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cdabd45..4d3ab51 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -110,15 +110,10 @@ namespace OpenSim.Region.Framework.Scenes
110 110
111 public UUID currentParcelUUID = UUID.Zero; 111 public UUID currentParcelUUID = UUID.Zero;
112 112
113 protected ScenePresenceAnimator m_animator;
114 /// <value> 113 /// <value>
115 /// The animator for this avatar 114 /// The animator for this avatar
116 /// </value> 115 /// </value>
117 public ScenePresenceAnimator Animator 116 public ScenePresenceAnimator Animator { get; private set; }
118 {
119 get { return m_animator; }
120 private set { m_animator = value; }
121 }
122 117
123 /// <summary> 118 /// <summary>
124 /// Attachments recorded on this avatar. 119 /// Attachments recorded on this avatar.
@@ -2763,8 +2758,7 @@ namespace OpenSim.Region.Framework.Scenes
2763 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); 2758 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
2764 2759
2765 avatar.ControllingClient.SendAvatarDataImmediate(this); 2760 avatar.ControllingClient.SendAvatarDataImmediate(this);
2766 if (Animator != null) 2761 Animator.SendAnimPackToClient(avatar.ControllingClient);
2767 Animator.SendAnimPackToClient(avatar.ControllingClient);
2768 } 2762 }
2769 2763
2770 /// <summary> 2764 /// <summary>
@@ -3440,6 +3434,16 @@ namespace OpenSim.Region.Framework.Scenes
3440 if (IsChildAgent) 3434 if (IsChildAgent)
3441 return; 3435 return;
3442 3436
3437 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
3438 // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
3439 // as of this comment the interval is set in AddToPhysicalScene
3440
3441// if (m_updateCount > 0)
3442// {
3443 Animator.UpdateMovementAnimations();
3444// m_updateCount--;
3445// }
3446
3443 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3447 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3444 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3448 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3445 3449
@@ -3453,7 +3457,7 @@ namespace OpenSim.Region.Framework.Scenes
3453// m_lastColCount = coldata.Count; 3457// m_lastColCount = coldata.Count;
3454// } 3458// }
3455 3459
3456 if (coldata.Count != 0 && Animator != null) 3460 if (coldata.Count != 0)
3457 { 3461 {
3458 switch (Animator.CurrentMovementAnimation) 3462 switch (Animator.CurrentMovementAnimation)
3459 { 3463 {
@@ -3565,7 +3569,7 @@ namespace OpenSim.Region.Framework.Scenes
3565 ControllingClient.SendHealth(Health); 3569 ControllingClient.SendHealth(Health);
3566 } 3570 }
3567 3571
3568 public void Close() 3572 protected internal void Close()
3569 { 3573 {
3570 // Clear known regions 3574 // Clear known regions
3571 KnownRegions = new Dictionary<ulong, string>(); 3575 KnownRegions = new Dictionary<ulong, string>();
@@ -3581,9 +3585,6 @@ namespace OpenSim.Region.Framework.Scenes
3581 // m_reprioritizationTimer.Dispose(); 3585 // m_reprioritizationTimer.Dispose();
3582 3586
3583 RemoveFromPhysicalScene(); 3587 RemoveFromPhysicalScene();
3584 if(Animator != null)
3585 Animator.Close();
3586 Animator = null;
3587 } 3588 }
3588 3589
3589 public void AddAttachment(SceneObjectGroup gobj) 3590 public void AddAttachment(SceneObjectGroup gobj)
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index d6ff5a2..20919a1 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -30,7 +30,7 @@ using System.Collections.Generic;
30using System.Timers; 30using System.Timers;
31using OpenMetaverse.Packets; 31using OpenMetaverse.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Statistics; 33using OpenSim.Framework.Monitoring;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35 35
36namespace OpenSim.Region.Framework.Scenes 36namespace OpenSim.Region.Framework.Scenes
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index 02c45ef..5758869 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -53,62 +53,94 @@ namespace OpenSim.Region.Framework.Scenes.Tests
53 /// Scene presence tests 53 /// Scene presence tests
54 /// </summary> 54 /// </summary>
55 [TestFixture] 55 [TestFixture]
56 public class ScenePresenceAgentTests 56 public class ScenePresenceAgentTests : OpenSimTestCase
57 { 57 {
58 public Scene scene, scene2, scene3; 58// public Scene scene, scene2, scene3;
59 public UUID agent1, agent2, agent3; 59// public UUID agent1, agent2, agent3;
60 public static Random random; 60// public static Random random;
61 public ulong region1,region2,region3; 61// public ulong region1, region2, region3;
62 public AgentCircuitData acd1; 62// public AgentCircuitData acd1;
63 public SceneObjectGroup sog1, sog2, sog3; 63// public TestClient testclient;
64 public TestClient testclient; 64
65 65// [TestFixtureSetUp]
66 [TestFixtureSetUp] 66// public void Init()
67 public void Init() 67// {
68//// TestHelpers.InMethod();
69////
70//// SceneHelpers sh = new SceneHelpers();
71////
72//// scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
73//// scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
74//// scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
75////
76//// ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
77//// interregionComms.Initialise(new IniConfigSource());
78//// interregionComms.PostInitialise();
79//// SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
80//// SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
81//// SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms);
82//
83//// agent1 = UUID.Random();
84//// agent2 = UUID.Random();
85//// agent3 = UUID.Random();
86//
87//// region1 = scene.RegionInfo.RegionHandle;
88//// region2 = scene2.RegionInfo.RegionHandle;
89//// region3 = scene3.RegionInfo.RegionHandle;
90// }
91
92 [Test]
93 public void TestCreateRootScenePresence()
68 { 94 {
69 TestHelpers.InMethod(); 95 TestHelpers.InMethod();
96// TestHelpers.EnableLogging();
97
98 UUID spUuid = TestHelpers.ParseTail(0x1);
70 99
71 SceneHelpers sh = new SceneHelpers(); 100 TestScene scene = new SceneHelpers().SetupScene();
72 101 SceneHelpers.AddScenePresence(scene, spUuid);
73 scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); 102
74 scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); 103 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null);
75 scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); 104 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
76 105
77 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 106 ScenePresence sp = scene.GetScenePresence(spUuid);
78 interregionComms.Initialise(new IniConfigSource()); 107 Assert.That(sp, Is.Not.Null);
79 interregionComms.PostInitialise(); 108 Assert.That(sp.IsChildAgent, Is.False);
80 SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); 109 Assert.That(sp.UUID, Is.EqualTo(spUuid));
81 SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); 110
82 SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); 111 Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1));
83
84 agent1 = UUID.Random();
85 agent2 = UUID.Random();
86 agent3 = UUID.Random();
87 random = new Random();
88 sog1 = SceneHelpers.CreateSceneObject(1, agent1);
89 scene.AddSceneObject(sog1);
90 sog2 = SceneHelpers.CreateSceneObject(1, agent1);
91 scene.AddSceneObject(sog2);
92 sog3 = SceneHelpers.CreateSceneObject(1, agent1);
93 scene.AddSceneObject(sog3);
94
95 region1 = scene.RegionInfo.RegionHandle;
96 region2 = scene2.RegionInfo.RegionHandle;
97 region3 = scene3.RegionInfo.RegionHandle;
98 } 112 }
99 113
100 [Test] 114 [Test]
101 public void TestCloseAgent() 115 public void TestCreateDuplicateRootScenePresence()
102 { 116 {
103 TestHelpers.InMethod(); 117 TestHelpers.InMethod();
104// TestHelpers.EnableLogging(); 118// TestHelpers.EnableLogging();
105 119
120 UUID spUuid = TestHelpers.ParseTail(0x1);
121
106 TestScene scene = new SceneHelpers().SetupScene(); 122 TestScene scene = new SceneHelpers().SetupScene();
107 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 123 SceneHelpers.AddScenePresence(scene, spUuid);
124 SceneHelpers.AddScenePresence(scene, spUuid);
108 125
109 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); 126 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null);
110 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); 127 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
111 128
129 ScenePresence sp = scene.GetScenePresence(spUuid);
130 Assert.That(sp, Is.Not.Null);
131 Assert.That(sp.IsChildAgent, Is.False);
132 Assert.That(sp.UUID, Is.EqualTo(spUuid));
133 }
134
135 [Test]
136 public void TestCloseAgent()
137 {
138 TestHelpers.InMethod();
139// TestHelpers.EnableLogging();
140
141 TestScene scene = new SceneHelpers().SetupScene();
142 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
143
112 scene.IncomingCloseAgent(sp.UUID); 144 scene.IncomingCloseAgent(sp.UUID);
113 145
114 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); 146 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
@@ -266,99 +298,99 @@ namespace OpenSim.Region.Framework.Scenes.Tests
266 // but things are synchronous among them. So there should be 298 // but things are synchronous among them. So there should be
267 // 3 threads in here. 299 // 3 threads in here.
268 //[Test] 300 //[Test]
269 public void T021_TestCrossToNewRegion() 301// public void T021_TestCrossToNewRegion()
270 { 302// {
271 TestHelpers.InMethod(); 303// TestHelpers.InMethod();
272 304//
273 scene.RegisterRegionWithGrid(); 305// scene.RegisterRegionWithGrid();
274 scene2.RegisterRegionWithGrid(); 306// scene2.RegisterRegionWithGrid();
275 307//
276 // Adding child agent to region 1001 308// // Adding child agent to region 1001
277 string reason; 309// string reason;
278 scene2.NewUserConnection(acd1,0, out reason); 310// scene2.NewUserConnection(acd1,0, out reason);
279 scene2.AddNewClient(testclient, PresenceType.User); 311// scene2.AddNewClient(testclient, PresenceType.User);
280 312//
281 ScenePresence presence = scene.GetScenePresence(agent1); 313// ScenePresence presence = scene.GetScenePresence(agent1);
282 presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); 314// presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
283 315//
284 ScenePresence presence2 = scene2.GetScenePresence(agent1); 316// ScenePresence presence2 = scene2.GetScenePresence(agent1);
285 317//
286 // Adding neighbour region caps info to presence2 318// // Adding neighbour region caps info to presence2
287 319//
288 string cap = presence.ControllingClient.RequestClientInfo().CapsPath; 320// string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
289 presence2.AddNeighbourRegion(region1, cap); 321// presence2.AddNeighbourRegion(region1, cap);
290 322//
291 Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region."); 323// Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region.");
292 Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region."); 324// Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region.");
293 325//
294 // Cross to x+1 326// // Cross to x+1
295 presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100); 327// presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100);
296 presence.Update(); 328// presence.Update();
297 329//
298 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); 330// EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
299 331//
300 // Mimicking communication between client and server, by waiting OK from client 332// // Mimicking communication between client and server, by waiting OK from client
301 // sent by TestClient.CrossRegion call. Originally, this is network comm. 333// // sent by TestClient.CrossRegion call. Originally, this is network comm.
302 if (!wh.WaitOne(5000,false)) 334// if (!wh.WaitOne(5000,false))
303 { 335// {
304 presence.Update(); 336// presence.Update();
305 if (!wh.WaitOne(8000,false)) 337// if (!wh.WaitOne(8000,false))
306 throw new ArgumentException("1 - Timeout waiting for signal/variable."); 338// throw new ArgumentException("1 - Timeout waiting for signal/variable.");
307 } 339// }
308 340//
309 // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which 341// // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which
310 // would normally be fired after receiving the reply packet from comm. done on the last line. 342// // would normally be fired after receiving the reply packet from comm. done on the last line.
311 testclient.CompleteMovement(); 343// testclient.CompleteMovement();
312 344//
313 // Crossings are asynchronous 345// // Crossings are asynchronous
314 int timer = 10; 346// int timer = 10;
315 347//
316 // Make sure cross hasn't already finished 348// // Make sure cross hasn't already finished
317 if (!presence.IsInTransit && !presence.IsChildAgent) 349// if (!presence.IsInTransit && !presence.IsChildAgent)
318 { 350// {
319 // If not and not in transit yet, give it some more time 351// // If not and not in transit yet, give it some more time
320 Thread.Sleep(5000); 352// Thread.Sleep(5000);
321 } 353// }
322 354//
323 // Enough time, should at least be in transit by now. 355// // Enough time, should at least be in transit by now.
324 while (presence.IsInTransit && timer > 0) 356// while (presence.IsInTransit && timer > 0)
325 { 357// {
326 Thread.Sleep(1000); 358// Thread.Sleep(1000);
327 timer-=1; 359// timer-=1;
328 } 360// }
329 361//
330 Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1."); 362// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1.");
331 Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected."); 363// Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
332 Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent."); 364// Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
333 365//
334 // Cross Back 366// // Cross Back
335 presence2.AbsolutePosition = new Vector3(-10, 3, 100); 367// presence2.AbsolutePosition = new Vector3(-10, 3, 100);
336 presence2.Update(); 368// presence2.Update();
337 369//
338 if (!wh.WaitOne(5000,false)) 370// if (!wh.WaitOne(5000,false))
339 { 371// {
340 presence2.Update(); 372// presence2.Update();
341 if (!wh.WaitOne(8000,false)) 373// if (!wh.WaitOne(8000,false))
342 throw new ArgumentException("2 - Timeout waiting for signal/variable."); 374// throw new ArgumentException("2 - Timeout waiting for signal/variable.");
343 } 375// }
344 testclient.CompleteMovement(); 376// testclient.CompleteMovement();
345 377//
346 if (!presence2.IsInTransit && !presence2.IsChildAgent) 378// if (!presence2.IsInTransit && !presence2.IsChildAgent)
347 { 379// {
348 // If not and not in transit yet, give it some more time 380// // If not and not in transit yet, give it some more time
349 Thread.Sleep(5000); 381// Thread.Sleep(5000);
350 } 382// }
351 383//
352 // Enough time, should at least be in transit by now. 384// // Enough time, should at least be in transit by now.
353 while (presence2.IsInTransit && timer > 0) 385// while (presence2.IsInTransit && timer > 0)
354 { 386// {
355 Thread.Sleep(1000); 387// Thread.Sleep(1000);
356 timer-=1; 388// timer-=1;
357 } 389// }
358 390//
359 Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2."); 391// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2.");
360 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); 392// Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
361 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); 393// Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
362 } 394// }
363 } 395 }
364} \ No newline at end of file 396} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index a407f01..37b5184 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -301,7 +301,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
301 sp.AbsolutePosition = preTeleportPosition; 301 sp.AbsolutePosition = preTeleportPosition;
302 302
303 // Make sceneB refuse CreateAgent 303 // Make sceneB refuse CreateAgent
304 sceneB.LoginsDisabled = true; 304 sceneB.LoginsEnabled = false;
305 305
306 sceneA.RequestTeleportLocation( 306 sceneA.RequestTeleportLocation(
307 sp.ControllingClient, 307 sp.ControllingClient,