aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs49
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs583
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs91
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs192
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs441
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs20
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs45
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs300
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs154
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs130
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs478
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs2
38 files changed, 1904 insertions, 949 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index e577958..9ddac19 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -294,6 +294,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
294 return "FALLDOWN"; 294 return "FALLDOWN";
295 } 295 }
296 296
297 // Check if the user has stopped walking just now
298 if (CurrentMovementAnimation == "WALK" && (move == Vector3.Zero))
299 return "STAND";
300
297 return CurrentMovementAnimation; 301 return CurrentMovementAnimation;
298 } 302 }
299 303
@@ -418,13 +422,16 @@ namespace OpenSim.Region.Framework.Scenes.Animation
418 /// </summary> 422 /// </summary>
419 public void UpdateMovementAnimations() 423 public void UpdateMovementAnimations()
420 { 424 {
421 CurrentMovementAnimation = DetermineMovementAnimation(); 425 lock (m_animations)
426 {
427 CurrentMovementAnimation = DetermineMovementAnimation();
422 428
423// m_log.DebugFormat( 429// m_log.DebugFormat(
424// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", 430// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()",
425// CurrentMovementAnimation, m_scenePresence.Name); 431// CurrentMovementAnimation, m_scenePresence.Name);
426 432
427 TrySetMovementAnimation(CurrentMovementAnimation); 433 TrySetMovementAnimation(CurrentMovementAnimation);
434 }
428 } 435 }
429 436
430 public UUID[] GetAnimationArray() 437 public UUID[] GetAnimationArray()
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index f678d07..f555b49 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
117 117
118 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) 118 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e)
119 { 119 {
120 m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop"); 120// m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop");
121 121
122 // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved 122 // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved
123 // in a culture where decimal points are commas and then reloaded in a culture which just treats them as 123 // in a culture where decimal points are commas and then reloaded in a culture which just treats them as
@@ -147,15 +147,15 @@ namespace OpenSim.Region.Framework.Scenes
147 { 147 {
148 x = m_inventoryDeletes.Dequeue(); 148 x = m_inventoryDeletes.Dequeue();
149 149
150 m_log.DebugFormat( 150// m_log.DebugFormat(
151 "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", 151// "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.",
152 left, x.action, x.objectGroups.Count); 152// left, x.action, x.objectGroups.Count);
153 153
154 try 154 try
155 { 155 {
156 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 156 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
157 if (invAccess != null) 157 if (invAccess != null)
158 invAccess.CopyToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient); 158 invAccess.CopyToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient, false);
159 159
160 if (x.permissionToDelete) 160 if (x.permissionToDelete)
161 { 161 {
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes
185 e.StackTrace); 185 e.StackTrace);
186 } 186 }
187 187
188 m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); 188// m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue.");
189 189
190 return false; 190 return false;
191 } 191 }
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 2365cfe..76a952b 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -53,6 +53,10 @@ namespace OpenSim.Region.Framework.Scenes
53 53
54 public event ClientMovement OnClientMovement; 54 public event ClientMovement OnClientMovement;
55 55
56 public delegate void OnTerrainTaintedDelegate();
57
58 public event OnTerrainTaintedDelegate OnTerrainTainted;
59
56 public delegate void OnTerrainTickDelegate(); 60 public delegate void OnTerrainTickDelegate();
57 61
58 public delegate void OnTerrainUpdateDelegate(); 62 public delegate void OnTerrainUpdateDelegate();
@@ -484,6 +488,9 @@ namespace OpenSim.Region.Framework.Scenes
484 public delegate void SceneObjectPartUpdated(SceneObjectPart sop); 488 public delegate void SceneObjectPartUpdated(SceneObjectPart sop);
485 public event SceneObjectPartUpdated OnSceneObjectPartUpdated; 489 public event SceneObjectPartUpdated OnSceneObjectPartUpdated;
486 490
491 public delegate void ScenePresenceUpdated(ScenePresence sp);
492 public event ScenePresenceUpdated OnScenePresenceUpdated;
493
487 public delegate void RegionUp(GridRegion region); 494 public delegate void RegionUp(GridRegion region);
488 public event RegionUp OnRegionUp; 495 public event RegionUp OnRegionUp;
489 496
@@ -935,6 +942,27 @@ namespace OpenSim.Region.Framework.Scenes
935 } 942 }
936 } 943 }
937 944
945 public void TriggerTerrainTainted()
946 {
947 OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted;
948 if (handlerTerrainTainted != null)
949 {
950 foreach (OnTerrainTaintedDelegate d in handlerTerrainTainted.GetInvocationList())
951 {
952 try
953 {
954 d();
955 }
956 catch (Exception e)
957 {
958 m_log.ErrorFormat(
959 "[EVENT MANAGER]: Delegate for TriggerTerrainTainted failed - continuing. {0} {1}",
960 e.Message, e.StackTrace);
961 }
962 }
963 }
964 }
965
938 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) 966 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
939 { 967 {
940 OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd; 968 OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd;
@@ -2367,6 +2395,27 @@ namespace OpenSim.Region.Framework.Scenes
2367 } 2395 }
2368 } 2396 }
2369 2397
2398 public void TriggerScenePresenceUpdated(ScenePresence sp)
2399 {
2400 ScenePresenceUpdated handler = OnScenePresenceUpdated;
2401 if (handler != null)
2402 {
2403 foreach (ScenePresenceUpdated d in handler.GetInvocationList())
2404 {
2405 try
2406 {
2407 d(sp);
2408 }
2409 catch (Exception e)
2410 {
2411 m_log.ErrorFormat(
2412 "[EVENT MANAGER]: Delegate for TriggerScenePresenceUpdated failed - continuing. {0} {1}",
2413 e.Message, e.StackTrace);
2414 }
2415 }
2416 }
2417 }
2418
2370 public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args, 2419 public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args,
2371 int local_id, IClientAPI remote_client) 2420 int local_id, IClientAPI remote_client)
2372 { 2421 {
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index 6c5685c..1365831 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -48,16 +48,19 @@ namespace OpenSim.Region.Framework.Scenes
48{ 48{
49 public class RegionStatsHandler : IStreamedRequestHandler 49 public class RegionStatsHandler : IStreamedRequestHandler
50 { 50 {
51 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
51 private string osRXStatsURI = String.Empty; 53 private string osRXStatsURI = String.Empty;
52 private string osXStatsURI = String.Empty; 54 private string osXStatsURI = String.Empty;
53 //private string osSecret = String.Empty; 55 //private string osSecret = String.Empty;
54 private OpenSim.Framework.RegionInfo regionInfo; 56 private OpenSim.Framework.RegionInfo regionInfo;
55 public string localZone = TimeZone.CurrentTimeZone.StandardName; 57 public string localZone = TimeZone.CurrentTimeZone.StandardName;
56 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); 58 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
57
58 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 59
60 public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info) 60 public string Name { get { return "RegionStats"; } }
61 public string Description { get { return "Region Statistics"; } }
62
63 public RegionStatsHandler(RegionInfo region_info)
61 { 64 {
62 regionInfo = region_info; 65 regionInfo = region_info;
63 osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret); 66 osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 29465c0..e1281a6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -300,6 +300,10 @@ namespace OpenSim.Region.Framework.Scenes
300 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); 300 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
301 AssetService.Store(asset); 301 AssetService.Store(asset);
302 302
303// m_log.DebugFormat(
304// "[PRIM INVENTORY]: Stored asset {0} when updating item {1} in prim {2} for {3}",
305// asset.ID, item.Name, part.Name, remoteClient.Name);
306
303 if (isScriptRunning) 307 if (isScriptRunning)
304 { 308 {
305 part.Inventory.RemoveScriptInstance(item.ItemID, false); 309 part.Inventory.RemoveScriptInstance(item.ItemID, false);
@@ -431,10 +435,9 @@ namespace OpenSim.Region.Framework.Scenes
431 } 435 }
432 else 436 else
433 { 437 {
434 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 438 if (AgentTransactionsModule != null)
435 if (agentTransactions != null)
436 { 439 {
437 agentTransactions.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); 440 AgentTransactionsModule.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
438 } 441 }
439 } 442 }
440 } 443 }
@@ -950,8 +953,8 @@ namespace OpenSim.Region.Framework.Scenes
950 sbyte invType, sbyte type, UUID olditemID) 953 sbyte invType, sbyte type, UUID olditemID)
951 { 954 {
952// m_log.DebugFormat( 955// m_log.DebugFormat(
953// "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}", 956// "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}, assetType {4}, inventoryType {5}",
954// remoteClient.Name, name, folderID, olditemID); 957// remoteClient.Name, name, folderID, olditemID, (AssetType)type, (InventoryType)invType);
955 958
956 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) 959 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
957 return; 960 return;
@@ -984,10 +987,10 @@ namespace OpenSim.Region.Framework.Scenes
984 asset.Type = type; 987 asset.Type = type;
985 asset.Name = name; 988 asset.Name = name;
986 asset.Description = description; 989 asset.Description = description;
987 990
988 CreateNewInventoryItem( 991 CreateNewInventoryItem(
989 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType, 992 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType,
990 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, 993 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All,
991 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); 994 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch());
992 } 995 }
993 else 996 else
@@ -1562,21 +1565,17 @@ namespace OpenSim.Region.Framework.Scenes
1562 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the 1565 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the
1563 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update) 1566 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update)
1564 // will not pass in a transaction ID in the update message. 1567 // will not pass in a transaction ID in the update message.
1565 if (transactionID != UUID.Zero) 1568 if (transactionID != UUID.Zero && AgentTransactionsModule != null)
1566 { 1569 {
1567 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 1570 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction(
1568 if (agentTransactions != null) 1571 remoteClient, part, transactionID, currentItem);
1569 { 1572
1570 agentTransactions.HandleTaskItemUpdateFromTransaction( 1573// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1571 remoteClient, part, transactionID, currentItem); 1574// remoteClient.SendAgentAlertMessage("Notecard saved", false);
1572 1575// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1573// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1576// remoteClient.SendAgentAlertMessage("Script saved", false);
1574// remoteClient.SendAgentAlertMessage("Notecard saved", false); 1577// else
1575// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) 1578// remoteClient.SendAgentAlertMessage("Item saved", false);
1576// remoteClient.SendAgentAlertMessage("Script saved", false);
1577// else
1578// remoteClient.SendAgentAlertMessage("Item saved", false);
1579 }
1580 } 1579 }
1581 1580
1582 // Base ALWAYS has move 1581 // Base ALWAYS has move
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 3ef1e29..cf68ff4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 public partial class Scene 39 public partial class Scene
40 { 40 {
41
41 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, 42 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
42 UUID fromID, bool fromAgent, bool broadcast) 43 UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
43 { 44 {
44 OSChatMessage args = new OSChatMessage(); 45 OSChatMessage args = new OSChatMessage();
45 46
@@ -63,14 +64,20 @@ namespace OpenSim.Region.Framework.Scenes
63 } 64 }
64 65
65 args.From = fromName; 66 args.From = fromName;
66 //args. 67 args.TargetUUID = targetID;
67 68
68 if (broadcast) 69 if (broadcast)
69 EventManager.TriggerOnChatBroadcast(this, args); 70 EventManager.TriggerOnChatBroadcast(this, args);
70 else 71 else
71 EventManager.TriggerOnChatFromWorld(this, args); 72 EventManager.TriggerOnChatFromWorld(this, args);
72 } 73 }
73 74
75 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
76 UUID fromID, bool fromAgent, bool broadcast)
77 {
78 SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
79 }
80
74 /// <summary> 81 /// <summary>
75 /// 82 ///
76 /// </summary> 83 /// </summary>
@@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes
108 { 115 {
109 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); 116 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true);
110 } 117 }
118 /// <summary>
119 ///
120 /// </summary>
121 /// <param name="message"></param>
122 /// <param name="type"></param>
123 /// <param name="fromPos"></param>
124 /// <param name="fromName"></param>
125 /// <param name="fromAgentID"></param>
126 /// <param name="targetID"></param>
127 public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
128 {
129 SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false);
130 }
111 131
112 /// <summary> 132 /// <summary>
113 /// Invoked when the client requests a prim. 133 /// Invoked when the client requests a prim.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index e1fedf4..535d87a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -67,6 +67,7 @@ namespace OpenSim.Region.Framework.Scenes
67 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); 67 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene);
68 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); 68 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
69 public delegate bool IsGodHandler(UUID user, Scene requestFromScene); 69 public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
70 public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene);
70 public delegate bool IsAdministratorHandler(UUID user); 71 public delegate bool IsAdministratorHandler(UUID user);
71 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); 72 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene);
72 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); 73 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene);
@@ -134,6 +135,7 @@ namespace OpenSim.Region.Framework.Scenes
134 public event RunConsoleCommandHandler OnRunConsoleCommand; 135 public event RunConsoleCommandHandler OnRunConsoleCommand;
135 public event IssueEstateCommandHandler OnIssueEstateCommand; 136 public event IssueEstateCommandHandler OnIssueEstateCommand;
136 public event IsGodHandler OnIsGod; 137 public event IsGodHandler OnIsGod;
138 public event IsGridGodHandler OnIsGridGod;
137 public event IsAdministratorHandler OnIsAdministrator; 139 public event IsAdministratorHandler OnIsAdministrator;
138// public event EditParcelHandler OnEditParcel; 140// public event EditParcelHandler OnEditParcel;
139 public event EditParcelPropertiesHandler OnEditParcelProperties; 141 public event EditParcelPropertiesHandler OnEditParcelProperties;
@@ -728,6 +730,21 @@ namespace OpenSim.Region.Framework.Scenes
728 return true; 730 return true;
729 } 731 }
730 732
733 public bool IsGridGod(UUID user)
734 {
735 IsGridGodHandler handler = OnIsGridGod;
736 if (handler != null)
737 {
738 Delegate[] list = handler.GetInvocationList();
739 foreach (IsGridGodHandler h in list)
740 {
741 if (h(user, m_scene) == false)
742 return false;
743 }
744 }
745 return true;
746 }
747
731 public bool IsAdministrator(UUID user) 748 public bool IsAdministrator(UUID user)
732 { 749 {
733 IsAdministratorHandler handler = OnIsAdministrator; 750 IsAdministratorHandler handler = OnIsAdministrator;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 6a120c1..3095382 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
@@ -217,6 +222,7 @@ namespace OpenSim.Region.Framework.Scenes
217 private int backupMS; 222 private int backupMS;
218 private int terrainMS; 223 private int terrainMS;
219 private int landMS; 224 private int landMS;
225 private int spareMS;
220 226
221 /// <summary> 227 /// <summary>
222 /// Tick at which the last frame was processed. 228 /// Tick at which the last frame was processed.
@@ -458,6 +464,7 @@ namespace OpenSim.Region.Framework.Scenes
458 { 464 {
459 if (m_simulationService == null) 465 if (m_simulationService == null)
460 m_simulationService = RequestModuleInterface<ISimulationService>(); 466 m_simulationService = RequestModuleInterface<ISimulationService>();
467
461 return m_simulationService; 468 return m_simulationService;
462 } 469 }
463 } 470 }
@@ -513,6 +520,8 @@ namespace OpenSim.Region.Framework.Scenes
513 } 520 }
514 521
515 public IAttachmentsModule AttachmentsModule { get; set; } 522 public IAttachmentsModule AttachmentsModule { get; set; }
523 public IEntityTransferModule EntityTransferModule { get; private set; }
524 public IAgentAssetTransactions AgentTransactionsModule { get; private set; }
516 525
517 public IAvatarFactoryModule AvatarFactory 526 public IAvatarFactoryModule AvatarFactory
518 { 527 {
@@ -589,6 +598,20 @@ namespace OpenSim.Region.Framework.Scenes
589 get { return m_sceneGraph.Entities; } 598 get { return m_sceneGraph.Entities; }
590 } 599 }
591 600
601
602 // used in sequence see: SpawnPoint()
603 private int m_SpawnPoint;
604 // can be closest/random/sequence
605 public string SpawnPointRouting
606 {
607 get; private set;
608 }
609 // allow landmarks to pass
610 public bool TelehubAllowLandmarks
611 {
612 get; private set;
613 }
614
592 #endregion Properties 615 #endregion Properties
593 616
594 #region Constructors 617 #region Constructors
@@ -606,7 +629,7 @@ namespace OpenSim.Region.Framework.Scenes
606 629
607 Random random = new Random(); 630 Random random = new Random();
608 631
609 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 632 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
610 m_moduleLoader = moduleLoader; 633 m_moduleLoader = moduleLoader;
611 m_authenticateHandler = authen; 634 m_authenticateHandler = authen;
612 m_sceneGridService = sceneGridService; 635 m_sceneGridService = sceneGridService;
@@ -726,6 +749,9 @@ namespace OpenSim.Region.Framework.Scenes
726 m_maxPhys = RegionInfo.PhysPrimMax; 749 m_maxPhys = RegionInfo.PhysPrimMax;
727 } 750 }
728 751
752 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
753 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
754
729 // Here, if clamping is requested in either global or 755 // Here, if clamping is requested in either global or
730 // local config, it will be used 756 // local config, it will be used
731 // 757 //
@@ -735,6 +761,7 @@ namespace OpenSim.Region.Framework.Scenes
735 m_clampPrimSize = true; 761 m_clampPrimSize = true;
736 } 762 }
737 763
764 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
738 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 765 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
739 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 766 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
740 m_dontPersistBefore = 767 m_dontPersistBefore =
@@ -833,13 +860,11 @@ namespace OpenSim.Region.Framework.Scenes
833 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 860 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
834 } 861 }
835 862
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) 863 public Scene(RegionInfo regInfo)
842 { 864 {
865 PhysicalPrims = true;
866 CollidablePrims = true;
867
843 BordersLocked = true; 868 BordersLocked = true;
844 Border northBorder = new Border(); 869 Border northBorder = new Border();
845 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- 870 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<---
@@ -866,8 +891,6 @@ namespace OpenSim.Region.Framework.Scenes
866 m_eventManager = new EventManager(); 891 m_eventManager = new EventManager();
867 892
868 m_permissions = new ScenePermissions(this); 893 m_permissions = new ScenePermissions(this);
869
870// m_lastUpdate = Util.EnvironmentTickCount();
871 } 894 }
872 895
873 #endregion 896 #endregion
@@ -936,8 +959,8 @@ namespace OpenSim.Region.Framework.Scenes
936 List<ulong> old = new List<ulong>(); 959 List<ulong> old = new List<ulong>();
937 old.Add(otherRegion.RegionHandle); 960 old.Add(otherRegion.RegionHandle);
938 agent.DropOldNeighbours(old); 961 agent.DropOldNeighbours(old);
939 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 962 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
940 m_teleportModule.EnableChildAgent(agent, otherRegion); 963 EntityTransferModule.EnableChildAgent(agent, otherRegion);
941 }); 964 });
942 } 965 }
943 catch (NullReferenceException) 966 catch (NullReferenceException)
@@ -950,7 +973,7 @@ namespace OpenSim.Region.Framework.Scenes
950 else 973 else
951 { 974 {
952 m_log.InfoFormat( 975 m_log.InfoFormat(
953 "[INTERGRID]: Got notice about far away Region: {0} at ({1}, {2})", 976 "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})",
954 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 977 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
955 } 978 }
956 } 979 }
@@ -1044,13 +1067,13 @@ namespace OpenSim.Region.Framework.Scenes
1044 } 1067 }
1045 } 1068 }
1046 1069
1070 m_log.Error("[REGION]: Closing");
1071 Close();
1072
1047 if (PhysicsScene != null) 1073 if (PhysicsScene != null)
1048 { 1074 {
1049 PhysicsScene.Dispose(); 1075 PhysicsScene.Dispose();
1050 } 1076 }
1051
1052 m_log.Error("[REGION]: Closing");
1053 Close();
1054 1077
1055 m_log.Error("[REGION]: Firing Region Restart Message"); 1078 m_log.Error("[REGION]: Firing Region Restart Message");
1056 1079
@@ -1074,8 +1097,8 @@ namespace OpenSim.Region.Framework.Scenes
1074 { 1097 {
1075 ForEachRootScenePresence(delegate(ScenePresence agent) 1098 ForEachRootScenePresence(delegate(ScenePresence agent)
1076 { 1099 {
1077 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 1100 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
1078 m_teleportModule.EnableChildAgent(agent, r); 1101 EntityTransferModule.EnableChildAgent(agent, r);
1079 }); 1102 });
1080 } 1103 }
1081 catch (NullReferenceException) 1104 catch (NullReferenceException)
@@ -1265,8 +1288,9 @@ namespace OpenSim.Region.Framework.Scenes
1265 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1288 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1266 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1289 m_dialogModule = RequestModuleInterface<IDialogModule>();
1267 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1290 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1268 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1291 EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
1269 m_groupsModule = RequestModuleInterface<IGroupsModule>(); 1292 m_groupsModule = RequestModuleInterface<IGroupsModule>();
1293 AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>();
1270 } 1294 }
1271 1295
1272 #endregion 1296 #endregion
@@ -1387,37 +1411,41 @@ namespace OpenSim.Region.Framework.Scenes
1387 endFrame = Frame + frames; 1411 endFrame = Frame + frames;
1388 1412
1389 float physicsFPS = 0f; 1413 float physicsFPS = 0f;
1390 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1414 int previousFrameTick, tmpMS;
1391 int previousFrameTick; 1415 int maintc = Util.EnvironmentTickCount();
1392 int maintc;
1393 int sleepMS;
1394 int framestart;
1395 1416
1396 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1417 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1397 { 1418 {
1398 framestart = Util.EnvironmentTickCount();
1399 ++Frame; 1419 ++Frame;
1400 1420
1401// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1421// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1402 1422
1403 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1423 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
1404 1424
1405 try 1425 try
1406 { 1426 {
1407 tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1427 // Apply taints in terrain module to terrain in physics scene
1428 if (Frame % m_update_terrain == 0)
1429 {
1430 tmpMS = Util.EnvironmentTickCount();
1431 UpdateTerrain();
1432 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1433 }
1434
1435 tmpMS = Util.EnvironmentTickCount();
1408 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1436 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1409 m_sceneGraph.UpdatePreparePhysics(); 1437 m_sceneGraph.UpdatePreparePhysics();
1410 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1438 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1411 1439
1412 // Apply any pending avatar force input to the avatar's velocity 1440 // Apply any pending avatar force input to the avatar's velocity
1413 tmpAgentMS = Util.EnvironmentTickCount(); 1441 tmpMS = Util.EnvironmentTickCount();
1414 if (Frame % m_update_entitymovement == 0) 1442 if (Frame % m_update_entitymovement == 0)
1415 m_sceneGraph.UpdateScenePresenceMovement(); 1443 m_sceneGraph.UpdateScenePresenceMovement();
1416 agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); 1444 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1417 1445
1418 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1446 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1419 // velocity 1447 // velocity
1420 tmpPhysicsMS = Util.EnvironmentTickCount(); 1448 tmpMS = Util.EnvironmentTickCount();
1421 if (Frame % m_update_physics == 0) 1449 if (Frame % m_update_physics == 0)
1422 { 1450 {
1423 if (m_physics_enabled) 1451 if (m_physics_enabled)
@@ -1426,9 +1454,9 @@ namespace OpenSim.Region.Framework.Scenes
1426 if (SynchronizeScene != null) 1454 if (SynchronizeScene != null)
1427 SynchronizeScene(this); 1455 SynchronizeScene(this);
1428 } 1456 }
1429 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); 1457 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1430 1458
1431 tmpAgentMS = Util.EnvironmentTickCount(); 1459 tmpMS = Util.EnvironmentTickCount();
1432 1460
1433 // Check if any objects have reached their targets 1461 // Check if any objects have reached their targets
1434 CheckAtTargets(); 1462 CheckAtTargets();
@@ -1443,36 +1471,29 @@ namespace OpenSim.Region.Framework.Scenes
1443 if (Frame % m_update_presences == 0) 1471 if (Frame % m_update_presences == 0)
1444 m_sceneGraph.UpdatePresences(); 1472 m_sceneGraph.UpdatePresences();
1445 1473
1446 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); 1474 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1447 1475
1448 // Delete temp-on-rez stuff 1476 // Delete temp-on-rez stuff
1449 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1477 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1450 { 1478 {
1451 tmpTempOnRezMS = Util.EnvironmentTickCount(); 1479 tmpMS = Util.EnvironmentTickCount();
1452 m_cleaningTemps = true; 1480 m_cleaningTemps = true;
1453 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1481 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1454 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1482 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1455 } 1483 }
1456 1484
1457 if (Frame % m_update_events == 0) 1485 if (Frame % m_update_events == 0)
1458 { 1486 {
1459 evMS = Util.EnvironmentTickCount(); 1487 tmpMS = Util.EnvironmentTickCount();
1460 UpdateEvents(); 1488 UpdateEvents();
1461 eventMS = Util.EnvironmentTickCountSubtract(evMS); 1489 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1462 } 1490 }
1463 1491
1464 if (Frame % m_update_backup == 0) 1492 if (Frame % m_update_backup == 0)
1465 { 1493 {
1466 backMS = Util.EnvironmentTickCount(); 1494 tmpMS = Util.EnvironmentTickCount();
1467 UpdateStorageBackup(); 1495 UpdateStorageBackup();
1468 backupMS = Util.EnvironmentTickCountSubtract(backMS); 1496 backupMS = Util.EnvironmentTickCountSubtract(tmpMS);
1469 }
1470
1471 if (Frame % m_update_terrain == 0)
1472 {
1473 terMS = Util.EnvironmentTickCount();
1474 UpdateTerrain();
1475 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1476 } 1497 }
1477 1498
1478 //if (Frame % m_update_land == 0) 1499 //if (Frame % m_update_land == 0)
@@ -1481,29 +1502,6 @@ namespace OpenSim.Region.Framework.Scenes
1481 // UpdateLand(); 1502 // UpdateLand();
1482 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1503 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1483 //} 1504 //}
1484
1485 // frameMS = Util.EnvironmentTickCountSubtract(maintc);
1486 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1487
1488 // if (Frame%m_update_avatars == 0)
1489 // UpdateInWorldTime();
1490 StatsReporter.AddPhysicsFPS(physicsFPS);
1491 StatsReporter.AddTimeDilation(TimeDilation);
1492 StatsReporter.AddFPS(1);
1493 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1494 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1495 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1496 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1497
1498 // frameMS currently records work frame times, not total frame times (work + any required sleep to
1499 // reach min frame time.
1500 // StatsReporter.addFrameMS(frameMS);
1501
1502 StatsReporter.addAgentMS(agentMS);
1503 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1504 StatsReporter.addOtherMS(otherMS);
1505 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1506 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1507 1505
1508 if (LoginsDisabled && Frame == 20) 1506 if (LoginsDisabled && Frame == 20)
1509 { 1507 {
@@ -1554,23 +1552,36 @@ namespace OpenSim.Region.Framework.Scenes
1554 1552
1555 previousFrameTick = m_lastFrameTick; 1553 previousFrameTick = m_lastFrameTick;
1556 m_lastFrameTick = Util.EnvironmentTickCount(); 1554 m_lastFrameTick = Util.EnvironmentTickCount();
1557 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); 1555 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1558 maintc = (int)(MinFrameTime * 1000) - maintc; 1556 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1559 1557
1560 m_firstHeartbeat = false; 1558 m_firstHeartbeat = false;
1561 1559
1560 if (tmpMS > 0)
1561 {
1562 Thread.Sleep(tmpMS);
1563 spareMS += tmpMS;
1564 }
1565
1566 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1567 maintc = Util.EnvironmentTickCount();
1562 1568
1563 sleepMS = Util.EnvironmentTickCount(); 1569 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1564 1570
1565 if (maintc > 0) 1571 // if (Frame%m_update_avatars == 0)
1566 Thread.Sleep(maintc); 1572 // UpdateInWorldTime();
1573 StatsReporter.AddPhysicsFPS(physicsFPS);
1574 StatsReporter.AddTimeDilation(TimeDilation);
1575 StatsReporter.AddFPS(1);
1567 1576
1568 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1569 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1570 StatsReporter.addSleepMS(sleepMS);
1571 StatsReporter.addFrameMS(frameMS); 1577 StatsReporter.addFrameMS(frameMS);
1572 1578 StatsReporter.addAgentMS(agentMS);
1573 // Optionally warn if a frame takes double the amount of time that it should. 1579 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1580 StatsReporter.addOtherMS(otherMS);
1581 StatsReporter.AddSpareMS(spareMS);
1582 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1583
1584 // Optionally warn if a frame takes double the amount of time that it should.
1574 if (DebugUpdates 1585 if (DebugUpdates
1575 && Util.EnvironmentTickCountSubtract( 1586 && Util.EnvironmentTickCountSubtract(
1576 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) 1587 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2))
@@ -2363,8 +2374,8 @@ namespace OpenSim.Region.Framework.Scenes
2363 return; 2374 return;
2364 } 2375 }
2365 2376
2366 if (m_teleportModule != null) 2377 if (EntityTransferModule != null)
2367 m_teleportModule.Cross(grp, attemptedPosition, silent); 2378 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2368 } 2379 }
2369 2380
2370 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2381 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2684,10 +2695,10 @@ namespace OpenSim.Region.Framework.Scenes
2684 { 2695 {
2685 SceneObjectGroup grp = sceneObject; 2696 SceneObjectGroup grp = sceneObject;
2686 2697
2687 m_log.DebugFormat( 2698// m_log.DebugFormat(
2688 "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); 2699// "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
2689 m_log.DebugFormat( 2700// m_log.DebugFormat(
2690 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2701// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2691 2702
2692 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2703 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2693 2704
@@ -2783,7 +2794,8 @@ namespace OpenSim.Region.Framework.Scenes
2783 if (sp == null) 2794 if (sp == null)
2784 { 2795 {
2785 m_log.DebugFormat( 2796 m_log.DebugFormat(
2786 "[SCENE]: Adding new child scene presence {0} to scene {1} at pos {2}", client.Name, RegionInfo.RegionName, client.StartPos); 2797 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}",
2798 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos);
2787 2799
2788 m_clientManager.Add(client); 2800 m_clientManager.Add(client);
2789 SubscribeToClientEvents(client); 2801 SubscribeToClientEvents(client);
@@ -3207,8 +3219,10 @@ namespace OpenSim.Region.Framework.Scenes
3207 /// <param name="client">The IClientAPI for the client</param> 3219 /// <param name="client">The IClientAPI for the client</param>
3208 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) 3220 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3209 { 3221 {
3210 if (m_teleportModule != null) 3222 if (EntityTransferModule != null)
3211 return m_teleportModule.TeleportHome(agentId, client); 3223 {
3224 EntityTransferModule.TeleportHome(agentId, client);
3225 }
3212 else 3226 else
3213 { 3227 {
3214 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3228 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
@@ -3370,55 +3384,70 @@ namespace OpenSim.Region.Framework.Scenes
3370// CheckHeartbeat(); 3384// CheckHeartbeat();
3371 bool isChildAgent = false; 3385 bool isChildAgent = false;
3372 ScenePresence avatar = GetScenePresence(agentID); 3386 ScenePresence avatar = GetScenePresence(agentID);
3373 if (avatar != null) 3387
3388 if (avatar == null)
3389 {
3390 m_log.WarnFormat(
3391 "[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID);
3392
3393 return;
3394 }
3395
3396 try
3374 { 3397 {
3375 isChildAgent = avatar.IsChildAgent; 3398 isChildAgent = avatar.IsChildAgent;
3376 3399
3377 if (avatar.ParentID != 0) 3400 m_log.DebugFormat(
3401 "[SCENE]: Removing {0} agent {1} {2} from {3}",
3402 (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName);
3403
3404 // Don't do this to root agents, it's not nice for the viewer
3405 if (closeChildAgents && isChildAgent)
3378 { 3406 {
3379 avatar.StandUp(); 3407 // Tell a single agent to disconnect from the region.
3408 IEventQueue eq = RequestModuleInterface<IEventQueue>();
3409 if (eq != null)
3410 {
3411 eq.DisableSimulator(RegionInfo.RegionHandle, avatar.UUID);
3412 }
3413 else
3414 {
3415 avatar.ControllingClient.SendShutdownConnectionNotice();
3416 }
3380 } 3417 }
3381 3418
3382 try 3419 // Only applies to root agents.
3420 if (avatar.ParentID != 0)
3383 { 3421 {
3384 m_log.DebugFormat( 3422 avatar.StandUp();
3385 "[SCENE]: Removing {0} agent {1} from region {2}", 3423 }
3386 (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName);
3387 3424
3388 m_sceneGraph.removeUserCount(!isChildAgent); 3425 m_sceneGraph.removeUserCount(!isChildAgent);
3389 3426
3390 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3427 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3391 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3428 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3392 if (closeChildAgents && CapsModule != null) 3429 if (closeChildAgents && CapsModule != null)
3393 CapsModule.RemoveCaps(agentID); 3430 CapsModule.RemoveCaps(agentID);
3394 3431
3395 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3432 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3396 // this method is doing is HORRIBLE!!! 3433 // this method is doing is HORRIBLE!!!
3397 avatar.Scene.NeedSceneCacheClear(avatar.UUID); 3434 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3398 3435
3399 if (closeChildAgents && !avatar.IsChildAgent) 3436 if (closeChildAgents && !isChildAgent)
3400 {
3401 List<ulong> regions = avatar.KnownRegionHandles;
3402 regions.Remove(RegionInfo.RegionHandle);
3403 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3404 }
3405 m_log.Debug("[Scene] Beginning ClientClosed");
3406 m_eventManager.TriggerClientClosed(agentID, this);
3407 m_log.Debug("[Scene] Finished ClientClosed");
3408 }
3409 catch (NullReferenceException)
3410 { 3437 {
3411 // We don't know which count to remove it from 3438 List<ulong> regions = avatar.KnownRegionHandles;
3412 // Avatar is already disposed :/ 3439 regions.Remove(RegionInfo.RegionHandle);
3440 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3413 } 3441 }
3414 3442
3415 try 3443 m_eventManager.TriggerClientClosed(agentID, this);
3444 m_eventManager.TriggerOnRemovePresence(agentID);
3445
3446 if (!isChildAgent)
3416 { 3447 {
3417 m_eventManager.TriggerOnRemovePresence(agentID); 3448 if (AttachmentsModule != null && avatar.PresenceType != PresenceType.Npc)
3418
3419 if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc)
3420 { 3449 {
3421 IUserManagement uMan = RequestModuleInterface<IUserManagement>(); 3450 IUserManagement uMan = RequestModuleInterface<IUserManagement>();
3422 // Don't save attachments for HG visitors, it 3451 // Don't save attachments for HG visitors, it
3423 // messes up their inventory. When a HG visitor logs 3452 // messes up their inventory. When a HG visitor logs
3424 // out on a foreign grid, their attachments will be 3453 // out on a foreign grid, their attachments will be
@@ -3428,7 +3457,7 @@ namespace OpenSim.Region.Framework.Scenes
3428 if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) 3457 if (uMan == null || uMan.IsLocalGridUser(avatar.UUID))
3429 AttachmentsModule.SaveChangedAttachments(avatar, false); 3458 AttachmentsModule.SaveChangedAttachments(avatar, false);
3430 } 3459 }
3431 3460
3432 ForEachClient( 3461 ForEachClient(
3433 delegate(IClientAPI client) 3462 delegate(IClientAPI client)
3434 { 3463 {
@@ -3436,43 +3465,35 @@ namespace OpenSim.Region.Framework.Scenes
3436 try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); } 3465 try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); }
3437 catch (NullReferenceException) { } 3466 catch (NullReferenceException) { }
3438 }); 3467 });
3439
3440 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
3441 if (agentTransactions != null)
3442 {
3443 agentTransactions.RemoveAgentAssetTransactions(agentID);
3444 }
3445 }
3446 finally
3447 {
3448 // Always clean these structures up so that any failure above doesn't cause them to remain in the
3449 // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
3450 // the same cleanup exception continually.
3451 // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
3452 // since this would hide the underlying failure and other associated problems.
3453 m_sceneGraph.RemoveScenePresence(agentID);
3454 m_clientManager.Remove(agentID);
3455 } 3468 }
3456 3469
3457 try 3470 // It's possible for child agents to have transactions if changes are being made cross-border.
3458 { 3471 if (AgentTransactionsModule != null)
3459 avatar.Close(); 3472 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3460 } 3473
3461 catch (NullReferenceException) 3474 avatar.Close();
3462 { 3475
3463 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
3464 }
3465 catch (Exception e)
3466 {
3467 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3468 }
3469 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3470 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3476 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3471// CleanDroppedAttachments();
3472 m_log.Debug("[Scene] The avatar has left the building"); 3477 m_log.Debug("[Scene] The avatar has left the building");
3473 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3474 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3475 } 3478 }
3479 catch (Exception e)
3480 {
3481 m_log.Error(
3482 string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e);
3483 }
3484 finally
3485 {
3486 // Always clean these structures up so that any failure above doesn't cause them to remain in the
3487 // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
3488 // the same cleanup exception continually.
3489 // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
3490 // since this would hide the underlying failure and other associated problems.
3491 m_sceneGraph.RemoveScenePresence(agentID);
3492 m_clientManager.Remove(agentID);
3493 }
3494
3495 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3496 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3476 } 3497 }
3477 3498
3478 /// <summary> 3499 /// <summary>
@@ -3554,7 +3575,7 @@ namespace OpenSim.Region.Framework.Scenes
3554 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) 3575 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup)
3555 { 3576 {
3556 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || 3577 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 ||
3557 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); 3578 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0);
3558 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); 3579 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0);
3559 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); 3580 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
3560 3581
@@ -3570,8 +3591,17 @@ namespace OpenSim.Region.Framework.Scenes
3570 // Don't disable this log message - it's too helpful 3591 // Don't disable this log message - it's too helpful
3571 m_log.DebugFormat( 3592 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})", 3593 "[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, 3594 RegionInfo.RegionName,
3574 agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); 3595 (agent.child ? "child" : "root"),
3596 agent.firstname,
3597 agent.lastname,
3598 agent.AgentID,
3599 agent.circuitcode,
3600 agent.IPAddress,
3601 agent.Viewer,
3602 ((TPFlags)teleportFlags).ToString(),
3603 agent.startpos
3604 );
3575 3605
3576 if (LoginsDisabled) 3606 if (LoginsDisabled)
3577 { 3607 {
@@ -3586,7 +3616,11 @@ namespace OpenSim.Region.Framework.Scenes
3586 // We have a zombie from a crashed session. 3616 // We have a zombie from a crashed session.
3587 // Or the same user is trying to be root twice here, won't work. 3617 // Or the same user is trying to be root twice here, won't work.
3588 // Kill it. 3618 // Kill it.
3589 m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); 3619 m_log.DebugFormat(
3620 "[SCENE]: Zombie scene presence detected for {0} in {1}",
3621 agent.AgentID,
3622 RegionInfo.RegionName
3623 );
3590 sp.ControllingClient.Close(); 3624 sp.ControllingClient.Close();
3591 sp = null; 3625 sp = null;
3592 } 3626 }
@@ -3613,8 +3647,7 @@ namespace OpenSim.Region.Framework.Scenes
3613 { 3647 {
3614 if (!VerifyUserPresence(agent, out reason)) 3648 if (!VerifyUserPresence(agent, out reason))
3615 return false; 3649 return false;
3616 } 3650 } catch (Exception e)
3617 catch (Exception e)
3618 { 3651 {
3619 m_log.ErrorFormat( 3652 m_log.ErrorFormat(
3620 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3653 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
@@ -3649,8 +3682,7 @@ namespace OpenSim.Region.Framework.Scenes
3649 CapsModule.SetAgentCapsSeeds(agent); 3682 CapsModule.SetAgentCapsSeeds(agent);
3650 CapsModule.CreateCaps(agent.AgentID); 3683 CapsModule.CreateCaps(agent.AgentID);
3651 } 3684 }
3652 } 3685 } else
3653 else
3654 { 3686 {
3655 // Let the SP know how we got here. This has a lot of interesting 3687 // Let the SP know how we got here. This has a lot of interesting
3656 // uses down the line. 3688 // uses down the line.
@@ -3673,7 +3705,7 @@ namespace OpenSim.Region.Framework.Scenes
3673 agent.teleportFlags = teleportFlags; 3705 agent.teleportFlags = teleportFlags;
3674 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3706 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3675 3707
3676 if (vialogin) 3708 if (vialogin)
3677 { 3709 {
3678// CleanDroppedAttachments(); 3710// CleanDroppedAttachments();
3679 3711
@@ -3714,8 +3746,7 @@ namespace OpenSim.Region.Framework.Scenes
3714 agent.startpos.Z = 720; 3746 agent.startpos.Z = 720;
3715 } 3747 }
3716 } 3748 }
3717 } 3749 } else
3718 else
3719 { 3750 {
3720 if (agent.startpos.X > EastBorders[0].BorderLine.Z) 3751 if (agent.startpos.X > EastBorders[0].BorderLine.Z)
3721 { 3752 {
@@ -3741,10 +3772,19 @@ namespace OpenSim.Region.Framework.Scenes
3741 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); 3772 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3742 // Can have multiple SpawnPoints 3773 // Can have multiple SpawnPoints
3743 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); 3774 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
3744 if ( spawnpoints.Count > 1) 3775 if (spawnpoints.Count > 1)
3745 { 3776 {
3746 // We have multiple SpawnPoints, Route the agent to a random one 3777 // 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); 3778 if (SpawnPointRouting == "random")
3779 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
3780 telehub.AbsolutePosition,
3781 telehub.GroupRotation
3782 );
3783 else
3784 agent.startpos = spawnpoints[SpawnPoint()].GetLocation(
3785 telehub.AbsolutePosition,
3786 telehub.GroupRotation
3787 );
3748 } 3788 }
3749 else 3789 else
3750 { 3790 {
@@ -3981,41 +4021,41 @@ namespace OpenSim.Region.Framework.Scenes
3981 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); 4021 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
3982 } 4022 }
3983 4023
3984 /// <summary> 4024// /// <summary>
3985 /// The Grid has requested that we log-off a user. Log them off. 4025// /// The Grid has requested that we log-off a user. Log them off.
3986 /// </summary> 4026// /// </summary>
3987 /// <param name="AvatarID">Unique ID of the avatar to log-off</param> 4027// /// <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> 4028// /// <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> 4029// /// <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) 4030// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3991 { 4031// {
3992 ScenePresence loggingOffUser = GetScenePresence(AvatarID); 4032// ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3993 if (loggingOffUser != null) 4033// if (loggingOffUser != null)
3994 { 4034// {
3995 UUID localRegionSecret = UUID.Zero; 4035// UUID localRegionSecret = UUID.Zero;
3996 bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); 4036// bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret);
3997 4037//
3998 // Region Secret is used here in case a new sessionid overwrites an old one on the user server. 4038// // 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. 4039// // Will update the user server in a few revisions to use it.
4000 4040//
4001 if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) 4041// if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret))
4002 { 4042// {
4003 m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); 4043// m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles);
4004 loggingOffUser.ControllingClient.Kick(message); 4044// loggingOffUser.ControllingClient.Kick(message);
4005 // Give them a second to receive the message! 4045// // Give them a second to receive the message!
4006 Thread.Sleep(1000); 4046// Thread.Sleep(1000);
4007 loggingOffUser.ControllingClient.Close(); 4047// loggingOffUser.ControllingClient.Close();
4008 } 4048// }
4009 else 4049// else
4010 { 4050// {
4011 m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); 4051// m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
4012 } 4052// }
4013 } 4053// }
4014 else 4054// else
4015 { 4055// {
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()); 4056// 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 } 4057// }
4018 } 4058// }
4019 4059
4020 /// <summary> 4060 /// <summary>
4021 /// Triggered when an agent crosses into this sim. Also happens on initial login. 4061 /// Triggered when an agent crosses into this sim. Also happens on initial login.
@@ -4068,21 +4108,19 @@ namespace OpenSim.Region.Framework.Scenes
4068 return false; 4108 return false;
4069 } 4109 }
4070 4110
4111 // TODO: This check should probably be in QueryAccess().
4071 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4112 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4072 if (nearestParcel == null) 4113 if (nearestParcel == null)
4073 { 4114 {
4074 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); 4115 m_log.DebugFormat(
4075 return false; 4116 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
4076 } 4117 cAgentData.AgentID, RegionInfo.RegionName);
4077
4078 int num = m_sceneGraph.GetNumberOfScenePresences();
4079 4118
4080 if (num >= RegionInfo.RegionSettings.AgentLimit) 4119 return false;
4081 {
4082 if (!Permissions.IsAdministrator(cAgentData.AgentID))
4083 return false;
4084 } 4120 }
4085 4121
4122 // We have to wait until the viewer contacts this region after receiving EAC.
4123 // That calls AddNewClient, which finally creates the ScenePresence
4086 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 4124 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
4087 4125
4088 if (childAgentUpdate != null) 4126 if (childAgentUpdate != null)
@@ -4126,14 +4164,28 @@ namespace OpenSim.Region.Framework.Scenes
4126 return false; 4164 return false;
4127 } 4165 }
4128 4166
4167 /// <summary>
4168 /// Poll until the requested ScenePresence appears or we timeout.
4169 /// </summary>
4170 /// <returns>The scene presence is found, else null.</returns>
4171 /// <param name='agentID'></param>
4129 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4172 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4130 { 4173 {
4131 int ntimes = 10; 4174 int ntimes = 10;
4132 ScenePresence childAgentUpdate = null; 4175 ScenePresence sp = null;
4133 while ((childAgentUpdate = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4176 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4134 Thread.Sleep(1000); 4177 Thread.Sleep(1000);
4135 return childAgentUpdate;
4136 4178
4179 if (sp == null)
4180 m_log.WarnFormat(
4181 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
4182 agentID, RegionInfo.RegionName);
4183// else
4184// m_log.DebugFormat(
4185// "[SCENE PRESENCE]: Found presence {0} {1} {2} in {3} after {4} waits",
4186// sp.Name, sp.UUID, sp.IsChildAgent ? "child" : "root", RegionInfo.RegionName, 10 - ntimes);
4187
4188 return sp;
4137 } 4189 }
4138 4190
4139 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) 4191 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent)
@@ -4171,33 +4223,7 @@ namespace OpenSim.Region.Framework.Scenes
4171 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4223 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4172 if (presence != null) 4224 if (presence != null)
4173 { 4225 {
4174 // Nothing is removed here, so down count it as such 4226 presence.ControllingClient.Close();
4175 if (presence.IsChildAgent)
4176 {
4177 m_sceneGraph.removeUserCount(false);
4178 }
4179 else if (!childOnly)
4180 {
4181 m_sceneGraph.removeUserCount(true);
4182 }
4183
4184 // Don't do this to root agents on logout, it's not nice for the viewer
4185 if (presence.IsChildAgent)
4186 {
4187 // Tell a single agent to disconnect from the region.
4188 IEventQueue eq = RequestModuleInterface<IEventQueue>();
4189 if (eq != null)
4190 {
4191 eq.DisableSimulator(RegionInfo.RegionHandle, agentID);
4192 }
4193 else
4194 presence.ControllingClient.SendShutdownConnectionNotice();
4195 presence.ControllingClient.Close(false);
4196 }
4197 else if (!childOnly)
4198 {
4199 presence.ControllingClient.Close(true);
4200 }
4201 return true; 4227 return true;
4202 } 4228 }
4203 4229
@@ -4283,8 +4309,10 @@ namespace OpenSim.Region.Framework.Scenes
4283 position.Y -= shifty; 4309 position.Y -= shifty;
4284 } 4310 }
4285 4311
4286 if (m_teleportModule != null) 4312 if (EntityTransferModule != null)
4287 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4313 {
4314 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4315 }
4288 else 4316 else
4289 { 4317 {
4290 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); 4318 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
@@ -4295,8 +4323,10 @@ namespace OpenSim.Region.Framework.Scenes
4295 4323
4296 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 4324 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4297 { 4325 {
4298 if (m_teleportModule != null) 4326 if (EntityTransferModule != null)
4299 return m_teleportModule.Cross(agent, isFlying); 4327 {
4328 return EntityTransferModule.Cross(agent, isFlying);
4329 }
4300 else 4330 else
4301 { 4331 {
4302 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 4332 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
@@ -5444,29 +5474,58 @@ Environment.Exit(1);
5444 throw new Exception(error); 5474 throw new Exception(error);
5445 } 5475 }
5446 5476
5447 // This method is called across the simulation connector to 5477 /// <summary>
5448 // determine if a given agent is allowed in this region 5478 /// This method is called across the simulation connector to
5449 // AS A ROOT AGENT. Returning false here will prevent them 5479 /// determine if a given agent is allowed in this region
5450 // from logging into the region, teleporting into the region 5480 /// AS A ROOT AGENT
5451 // or corssing the broder walking, but will NOT prevent 5481 /// </summary>
5452 // child agent creation, thereby emulating the SL behavior. 5482 /// <remarks>
5483 /// Returning false here will prevent them
5484 /// from logging into the region, teleporting into the region
5485 /// or corssing the broder walking, but will NOT prevent
5486 /// child agent creation, thereby emulating the SL behavior.
5487 /// </remarks>
5488 /// <param name='agentID'></param>
5489 /// <param name='position'></param>
5490 /// <param name='reason'></param>
5491 /// <returns></returns>
5453 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5492 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5454 { 5493 {
5455 reason = "You are banned from the region"; 5494 reason = "You are banned from the region";
5456 5495
5496 if (EntityTransferModule.IsInTransit(agentID))
5497 {
5498 reason = "Agent is still in transit from this region";
5499
5500 m_log.WarnFormat(
5501 "[SCENE]: Denying agent {0} entry into {1} since region still has them registered as in transit",
5502 agentID, RegionInfo.RegionName);
5503
5504 return false;
5505 }
5506
5457 if (Permissions.IsGod(agentID)) 5507 if (Permissions.IsGod(agentID))
5458 { 5508 {
5459 reason = String.Empty; 5509 reason = String.Empty;
5460 return true; 5510 return true;
5461 } 5511 }
5462 5512
5463 int num = m_sceneGraph.GetNumberOfScenePresences(); 5513 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5514 // However, the long term fix is to make sure root agent count is always accurate.
5515 m_sceneGraph.RecalculateStats();
5516
5517 int num = m_sceneGraph.GetRootAgentCount();
5464 5518
5465 if (num >= RegionInfo.RegionSettings.AgentLimit) 5519 if (num >= RegionInfo.RegionSettings.AgentLimit)
5466 { 5520 {
5467 if (!Permissions.IsAdministrator(agentID)) 5521 if (!Permissions.IsAdministrator(agentID))
5468 { 5522 {
5469 reason = "The region is full"; 5523 reason = "The region is full";
5524
5525 m_log.DebugFormat(
5526 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}",
5527 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit);
5528
5470 return false; 5529 return false;
5471 } 5530 }
5472 } 5531 }
@@ -5637,5 +5696,19 @@ Environment.Exit(1);
5637 } 5696 }
5638 } 5697 }
5639 } 5698 }
5699
5700 // manage and select spawn points in sequence
5701 public int SpawnPoint()
5702 {
5703 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
5704
5705 if (spawnpoints == 0)
5706 return 0;
5707
5708 m_SpawnPoint++;
5709 if (m_SpawnPoint > spawnpoints)
5710 m_SpawnPoint = 1;
5711 return m_SpawnPoint - 1;
5712 }
5640 } 5713 }
5641} 5714}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index b806d91..c1414ee 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -84,16 +84,16 @@ namespace OpenSim.Region.Framework.Scenes
84 if (neighbourService != null) 84 if (neighbourService != null)
85 neighbour = neighbourService.HelloNeighbour(regionhandle, region); 85 neighbour = neighbourService.HelloNeighbour(regionhandle, region);
86 else 86 else
87 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region"); 87 m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: No neighbour service provided for informing neigbhours of this region");
88 88
89 if (neighbour != null) 89 if (neighbour != null)
90 { 90 {
91 // m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); 91 m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
92 m_scene.EventManager.TriggerOnRegionUp(neighbour); 92 m_scene.EventManager.TriggerOnRegionUp(neighbour);
93 } 93 }
94 else 94 else
95 { 95 {
96 m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); 96 m_log.InfoFormat("[SCENE COMMUNICATION SERVICE]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
97 } 97 }
98 } 98 }
99 99
@@ -102,7 +102,7 @@ namespace OpenSim.Region.Framework.Scenes
102 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 102 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
103 103
104 List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); 104 List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);
105 //m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); 105 m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that this region is up", neighbours.Count);
106 foreach (GridRegion n in neighbours) 106 foreach (GridRegion n in neighbours)
107 { 107 {
108 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; 108 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
@@ -156,7 +156,9 @@ namespace OpenSim.Region.Framework.Scenes
156 // that the region position is cached or performance will degrade 156 // that the region position is cached or performance will degrade
157 Utils.LongToUInts(regionHandle, out x, out y); 157 Utils.LongToUInts(regionHandle, out x, out y);
158 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); 158 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
159// bool v = true; 159 if (dest == null)
160 continue;
161
160 if (!simulatorList.Contains(dest.ServerURI)) 162 if (!simulatorList.Contains(dest.ServerURI))
161 { 163 {
162 // we havent seen this simulator before, add it to the list 164 // we havent seen this simulator before, add it to the list
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index b7466be..4c12496 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -101,6 +101,13 @@ namespace OpenSim.Region.Framework.Scenes
101 /// </summary> 101 /// </summary>
102 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); 102 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>();
103 103
104 /// <summary>
105 /// Lock to prevent object group update, linking, delinking and duplication operations from running concurrently.
106 /// </summary>
107 /// <remarks>
108 /// These operations rely on the parts composition of the object. If allowed to run concurrently then race
109 /// conditions can occur.
110 /// </remarks>
104 private Object m_updateLock = new Object(); 111 private Object m_updateLock = new Object();
105 112
106 #endregion 113 #endregion
@@ -775,12 +782,6 @@ namespace OpenSim.Region.Framework.Scenes
775 782
776 public int GetChildAgentCount() 783 public int GetChildAgentCount()
777 { 784 {
778 // some network situations come in where child agents get closed twice.
779 if (m_numChildAgents < 0)
780 {
781 m_numChildAgents = 0;
782 }
783
784 return m_numChildAgents; 785 return m_numChildAgents;
785 } 786 }
786 787
@@ -852,11 +853,6 @@ namespace OpenSim.Region.Framework.Scenes
852 return m_scenePresenceArray; 853 return m_scenePresenceArray;
853 } 854 }
854 855
855 public int GetNumberOfScenePresences()
856 {
857 return m_scenePresenceArray.Count;
858 }
859
860 /// <summary> 856 /// <summary>
861 /// Request a scene presence by UUID. Fast, indexed lookup. 857 /// Request a scene presence by UUID. Fast, indexed lookup.
862 /// </summary> 858 /// </summary>
@@ -2063,12 +2059,14 @@ namespace OpenSim.Region.Framework.Scenes
2063 /// <param name="AgentID"></param> 2059 /// <param name="AgentID"></param>
2064 /// <param name="GroupID"></param> 2060 /// <param name="GroupID"></param>
2065 /// <param name="rot"></param> 2061 /// <param name="rot"></param>
2062 /// <returns>null if duplication fails, otherwise the duplicated object</returns>
2063 /// <summary>
2066 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 2064 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot)
2067 { 2065 {
2068// m_log.DebugFormat( 2066// m_log.DebugFormat(
2069// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", 2067// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
2070// originalPrimID, offset, AgentID); 2068// originalPrimID, offset, AgentID);
2071 2069
2072 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 2070 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
2073 if (original != null) 2071 if (original != null)
2074 { 2072 {
@@ -2098,25 +2096,25 @@ namespace OpenSim.Region.Framework.Scenes
2098 2096
2099 // FIXME: This section needs to be refactored so that it just calls AddSceneObject() 2097 // FIXME: This section needs to be refactored so that it just calls AddSceneObject()
2100 Entities.Add(copy); 2098 Entities.Add(copy);
2101 2099
2102 lock (SceneObjectGroupsByFullID) 2100 lock (SceneObjectGroupsByFullID)
2103 SceneObjectGroupsByFullID[copy.UUID] = copy; 2101 SceneObjectGroupsByFullID[copy.UUID] = copy;
2104 2102
2105 SceneObjectPart[] children = copy.Parts; 2103 SceneObjectPart[] children = copy.Parts;
2106 2104
2107 lock (SceneObjectGroupsByFullPartID) 2105 lock (SceneObjectGroupsByFullPartID)
2108 { 2106 {
2109 SceneObjectGroupsByFullPartID[copy.UUID] = copy; 2107 SceneObjectGroupsByFullPartID[copy.UUID] = copy;
2110 foreach (SceneObjectPart part in children) 2108 foreach (SceneObjectPart part in children)
2111 SceneObjectGroupsByFullPartID[part.UUID] = copy; 2109 SceneObjectGroupsByFullPartID[part.UUID] = copy;
2112 } 2110 }
2113 2111
2114 lock (SceneObjectGroupsByLocalPartID) 2112 lock (SceneObjectGroupsByLocalPartID)
2115 { 2113 {
2116 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; 2114 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
2117 foreach (SceneObjectPart part in children) 2115 foreach (SceneObjectPart part in children)
2118 SceneObjectGroupsByLocalPartID[part.LocalId] = copy; 2116 SceneObjectGroupsByLocalPartID[part.LocalId] = copy;
2119 } 2117 }
2120 // PROBABLE END OF FIXME 2118 // PROBABLE END OF FIXME
2121 2119
2122 // Since we copy from a source group that is in selected 2120 // Since we copy from a source group that is in selected
@@ -2148,11 +2146,10 @@ namespace OpenSim.Region.Framework.Scenes
2148 { 2146 {
2149 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); 2147 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
2150 } 2148 }
2151 2149
2152 return null; 2150 return null;
2153 } 2151 }
2154 2152
2155 /// <summary>
2156 /// Calculates the distance between two Vector3s 2153 /// Calculates the distance between two Vector3s
2157 /// </summary> 2154 /// </summary>
2158 /// <param name="v1"></param> 2155 /// <param name="v1"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 8fa7880..904c896 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2670,6 +2670,10 @@ namespace OpenSim.Region.Framework.Scenes
2670 /// <summary> 2670 /// <summary>
2671 /// Link the prims in a given group to this group 2671 /// Link the prims in a given group to this group
2672 /// </summary> 2672 /// </summary>
2673 /// <remarks>
2674 /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads.
2675 /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition.
2676 /// </remarks>
2673 /// <param name="objectGroup">The group of prims which should be linked to this group</param> 2677 /// <param name="objectGroup">The group of prims which should be linked to this group</param>
2674 public void LinkToGroup(SceneObjectGroup objectGroup) 2678 public void LinkToGroup(SceneObjectGroup objectGroup)
2675 { 2679 {
@@ -2751,6 +2755,7 @@ namespace OpenSim.Region.Framework.Scenes
2751 } 2755 }
2752 2756
2753 linkPart.LinkNum = linkNum++; 2757 linkPart.LinkNum = linkNum++;
2758 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2754 2759
2755 SceneObjectPart[] ogParts = objectGroup.Parts; 2760 SceneObjectPart[] ogParts = objectGroup.Parts;
2756 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 2761 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
@@ -2802,6 +2807,11 @@ namespace OpenSim.Region.Framework.Scenes
2802 /// Delink the given prim from this group. The delinked prim is established as 2807 /// Delink the given prim from this group. The delinked prim is established as
2803 /// an independent SceneObjectGroup. 2808 /// an independent SceneObjectGroup.
2804 /// </summary> 2809 /// </summary>
2810 /// <remarks>
2811 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2812 /// condition. But currently there is no
2813 /// alternative method that does take a lonk to delink a single prim.
2814 /// </remarks>
2805 /// <param name="partID"></param> 2815 /// <param name="partID"></param>
2806 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2816 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2807 public SceneObjectGroup DelinkFromGroup(uint partID) 2817 public SceneObjectGroup DelinkFromGroup(uint partID)
@@ -2813,6 +2823,11 @@ namespace OpenSim.Region.Framework.Scenes
2813 /// Delink the given prim from this group. The delinked prim is established as 2823 /// Delink the given prim from this group. The delinked prim is established as
2814 /// an independent SceneObjectGroup. 2824 /// an independent SceneObjectGroup.
2815 /// </summary> 2825 /// </summary>
2826 /// <remarks>
2827 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2828 /// condition. But currently there is no
2829 /// alternative method that does take a lonk to delink a single prim.
2830 /// </remarks>
2816 /// <param name="partID"></param> 2831 /// <param name="partID"></param>
2817 /// <param name="sendEvents"></param> 2832 /// <param name="sendEvents"></param>
2818 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2833 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
@@ -2838,6 +2853,11 @@ namespace OpenSim.Region.Framework.Scenes
2838 /// Delink the given prim from this group. The delinked prim is established as 2853 /// Delink the given prim from this group. The delinked prim is established as
2839 /// an independent SceneObjectGroup. 2854 /// an independent SceneObjectGroup.
2840 /// </summary> 2855 /// </summary>
2856 /// <remarks>
2857 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2858 /// condition. But currently there is no
2859 /// alternative method that does take a lonk to delink a single prim.
2860 /// </remarks>
2841 /// <param name="partID"></param> 2861 /// <param name="partID"></param>
2842 /// <param name="sendEvents"></param> 2862 /// <param name="sendEvents"></param>
2843 /// <returns>The object group of the newly delinked prim.</returns> 2863 /// <returns>The object group of the newly delinked prim.</returns>
@@ -2971,6 +2991,8 @@ namespace OpenSim.Region.Framework.Scenes
2971 oldRot = part.RotationOffset; 2991 oldRot = part.RotationOffset;
2972 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; 2992 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot;
2973 part.RotationOffset = newRot; 2993 part.RotationOffset = newRot;
2994
2995 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2974 } 2996 }
2975 2997
2976 /// <summary> 2998 /// <summary>
@@ -3482,7 +3504,7 @@ namespace OpenSim.Region.Framework.Scenes
3482 3504
3483 //we need to do a terse update even if the move wasn't allowed 3505 //we need to do a terse update even if the move wasn't allowed
3484 // so that the position is reset in the client (the object snaps back) 3506 // so that the position is reset in the client (the object snaps back)
3485 ScheduleGroupForTerseUpdate(); 3507 RootPart.ScheduleTerseUpdate();
3486 } 3508 }
3487 3509
3488 /// <summary> 3510 /// <summary>
@@ -4183,7 +4205,72 @@ namespace OpenSim.Region.Framework.Scenes
4183 for (int i = 0; i < parts.Length; i++) 4205 for (int i = 0; i < parts.Length; i++)
4184 parts[i].TriggerScriptChangedEvent(val); 4206 parts[i].TriggerScriptChangedEvent(val);
4185 } 4207 }
4186 4208
4209 /// <summary>
4210 /// Returns a count of the number of scripts in this groups parts.
4211 /// </summary>
4212 public int ScriptCount()
4213 {
4214 int count = 0;
4215 SceneObjectPart[] parts = m_parts.GetArray();
4216 for (int i = 0; i < parts.Length; i++)
4217 count += parts[i].Inventory.ScriptCount();
4218
4219 return count;
4220 }
4221
4222 /// <summary>
4223 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
4224 /// </summary>
4225 public float ScriptExecutionTime()
4226 {
4227 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
4228
4229 if (engines.Length == 0) // No engine at all
4230 return 0.0f;
4231
4232 float time = 0.0f;
4233
4234 // get all the scripts in all parts
4235 SceneObjectPart[] parts = m_parts.GetArray();
4236 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
4237 for (int i = 0; i < parts.Length; i++)
4238 {
4239 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
4240 }
4241 // extract the UUIDs
4242 List<UUID> ids = new List<UUID>(scripts.Count);
4243 foreach (TaskInventoryItem script in scripts)
4244 {
4245 if (!ids.Contains(script.ItemID))
4246 {
4247 ids.Add(script.ItemID);
4248 }
4249 }
4250 // Offer the list of script UUIDs to each engine found and accumulate the time
4251 foreach (IScriptModule e in engines)
4252 {
4253 if (e != null)
4254 {
4255 time += e.GetScriptExecutionTime(ids);
4256 }
4257 }
4258 return time;
4259 }
4260
4261 /// <summary>
4262 /// Returns a count of the number of running scripts in this groups parts.
4263 /// </summary>
4264 public int RunningScriptCount()
4265 {
4266 int count = 0;
4267 SceneObjectPart[] parts = m_parts.GetArray();
4268 for (int i = 0; i < parts.Length; i++)
4269 count += parts[i].Inventory.RunningScriptCount();
4270
4271 return count;
4272 }
4273
4187 public override string ToString() 4274 public override string ToString()
4188 { 4275 {
4189 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4276 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 8e74dc8..61ef827 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1016,7 +1016,18 @@ namespace OpenSim.Region.Framework.Scenes
1016 public int LinkNum 1016 public int LinkNum
1017 { 1017 {
1018 get { return m_linkNum; } 1018 get { return m_linkNum; }
1019 set { m_linkNum = value; } 1019 set
1020 {
1021// if (ParentGroup != null)
1022// {
1023// m_log.DebugFormat(
1024// "[SCENE OBJECT PART]: Setting linknum of {0}@{1} to {2} from {3}",
1025// Name, AbsolutePosition, value, m_linkNum);
1026// Util.PrintCallStack();
1027// }
1028
1029 m_linkNum = value;
1030 }
1020 } 1031 }
1021 1032
1022 public byte ClickAction 1033 public byte ClickAction
@@ -2153,6 +2164,9 @@ namespace OpenSim.Region.Framework.Scenes
2153 /// <param name="isNew"></param> 2164 /// <param name="isNew"></param>
2154 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) 2165 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
2155 { 2166 {
2167 if (ParentGroup.Scene == null)
2168 return;
2169
2156 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) 2170 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics)
2157 return; 2171 return;
2158 2172
@@ -3631,7 +3645,6 @@ namespace OpenSim.Region.Framework.Scenes
3631 hasProfileCut = hasDimple; // is it the same thing? 3645 hasProfileCut = hasDimple; // is it the same thing?
3632 } 3646 }
3633 3647
3634
3635 public void SetGroup(UUID groupID, IClientAPI client) 3648 public void SetGroup(UUID groupID, IClientAPI client)
3636 { 3649 {
3637 // Scene.AddNewPrims() calls with client == null so can't use this. 3650 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3661,10 +3674,12 @@ namespace OpenSim.Region.Framework.Scenes
3661 3674
3662 public void SetPhysicsAxisRotation() 3675 public void SetPhysicsAxisRotation()
3663 { 3676 {
3664 if (PhysActor != null) 3677 PhysicsActor pa = PhysActor;
3678
3679 if (pa != null)
3665 { 3680 {
3666 PhysActor.LockAngularMotion(RotationAxis); 3681 pa.LockAngularMotion(RotationAxis);
3667 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 3682 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
3668 } 3683 }
3669 } 3684 }
3670 3685
@@ -4381,7 +4396,7 @@ namespace OpenSim.Region.Framework.Scenes
4381 // For now, we use the NINJA naming scheme for identifying joints. 4396 // For now, we use the NINJA naming scheme for identifying joints.
4382 // In the future, we can support other joint specification schemes such as a 4397 // In the future, we can support other joint specification schemes such as a
4383 // custom checkbox in the viewer GUI. 4398 // custom checkbox in the viewer GUI.
4384 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4399 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4385 { 4400 {
4386 string hingeString = "hingejoint"; 4401 string hingeString = "hingejoint";
4387 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); 4402 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
@@ -4397,7 +4412,7 @@ namespace OpenSim.Region.Framework.Scenes
4397 // For now, we use the NINJA naming scheme for identifying joints. 4412 // For now, we use the NINJA naming scheme for identifying joints.
4398 // In the future, we can support other joint specification schemes such as a 4413 // In the future, we can support other joint specification schemes such as a
4399 // custom checkbox in the viewer GUI. 4414 // custom checkbox in the viewer GUI.
4400 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4415 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4401 { 4416 {
4402 string ballString = "balljoint"; 4417 string ballString = "balljoint";
4403 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); 4418 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
@@ -4413,7 +4428,7 @@ namespace OpenSim.Region.Framework.Scenes
4413 // For now, we use the NINJA naming scheme for identifying joints. 4428 // For now, we use the NINJA naming scheme for identifying joints.
4414 // In the future, we can support other joint specification schemes such as a 4429 // In the future, we can support other joint specification schemes such as a
4415 // custom checkbox in the viewer GUI. 4430 // custom checkbox in the viewer GUI.
4416 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4431 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4417 { 4432 {
4418 return IsHingeJoint() || IsBallJoint(); 4433 return IsHingeJoint() || IsBallJoint();
4419 } 4434 }
@@ -4534,7 +4549,6 @@ namespace OpenSim.Region.Framework.Scenes
4534 } 4549 }
4535 */ 4550 */
4536 } 4551 }
4537
4538 else // it already has a physical representation 4552 else // it already has a physical representation
4539 { 4553 {
4540 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. 4554 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 959046a..81477e7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -176,16 +176,14 @@ namespace OpenSim.Region.Framework.Scenes
176 /// <param name="ownerId"></param> 176 /// <param name="ownerId"></param>
177 public void ChangeInventoryOwner(UUID ownerId) 177 public void ChangeInventoryOwner(UUID ownerId)
178 { 178 {
179 m_items.LockItemsForWrite(true); 179 List<TaskInventoryItem> items = GetInventoryItems();
180 if (0 == Items.Count) 180
181 { 181 if (items.Count == 0)
182 m_items.LockItemsForWrite(false);
183 return; 182 return;
184 }
185 183
184 m_items.LockItemsForWrite(true);
186 HasInventoryChanged = true; 185 HasInventoryChanged = true;
187 m_part.ParentGroup.HasGroupChanged = true; 186 m_part.ParentGroup.HasGroupChanged = true;
188 List<TaskInventoryItem> items = GetInventoryItems();
189 foreach (TaskInventoryItem item in items) 187 foreach (TaskInventoryItem item in items)
190 { 188 {
191 if (ownerId != item.OwnerID) 189 if (ownerId != item.OwnerID)
@@ -267,14 +265,9 @@ namespace OpenSim.Region.Framework.Scenes
267 /// </summary> 265 /// </summary>
268 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) 266 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
269 { 267 {
270 Items.LockItemsForRead(true); 268 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
271 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 269 foreach (TaskInventoryItem item in scripts)
272 Items.LockItemsForRead(false); 270 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
273 foreach (TaskInventoryItem item in items)
274 {
275 if ((int)InventoryType.LSL == item.InvType)
276 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
277 }
278 } 271 }
279 272
280 public ArrayList GetScriptErrors(UUID itemID) 273 public ArrayList GetScriptErrors(UUID itemID)
@@ -305,17 +298,11 @@ namespace OpenSim.Region.Framework.Scenes
305 /// </param> 298 /// </param>
306 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 299 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
307 { 300 {
308 Items.LockItemsForRead(true); 301 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
309 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 302 foreach (TaskInventoryItem item in scripts)
310 Items.LockItemsForRead(false);
311
312 foreach (TaskInventoryItem item in items)
313 { 303 {
314 if ((int)InventoryType.LSL == item.InvType) 304 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
315 { 305 m_part.RemoveScriptEvents(item.ItemID);
316 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
317 m_part.RemoveScriptEvents(item.ItemID);
318 }
319 } 306 }
320 } 307 }
321 308
@@ -770,14 +757,22 @@ namespace OpenSim.Region.Framework.Scenes
770 return item; 757 return item;
771 } 758 }
772 759
773 /// <summary> 760 public TaskInventoryItem GetInventoryItem(string name)
774 /// Get inventory items by name. 761 {
775 /// </summary> 762 m_items.LockItemsForRead(true);
776 /// <param name="name"></param> 763 foreach (TaskInventoryItem item in m_items.Values)
777 /// <returns> 764 {
778 /// A list of inventory items with that name. 765 if (item.Name == name)
779 /// If no inventory item has that name then an empty list is returned. 766 {
780 /// </returns> 767 m_items.LockItemsForRead(false);
768 return item;
769 }
770 }
771 m_items.LockItemsForRead(false);
772
773 return null;
774 }
775
781 public List<TaskInventoryItem> GetInventoryItems(string name) 776 public List<TaskInventoryItem> GetInventoryItems(string name)
782 { 777 {
783 List<TaskInventoryItem> items = new List<TaskInventoryItem>(); 778 List<TaskInventoryItem> items = new List<TaskInventoryItem>();
@@ -1247,10 +1242,10 @@ namespace OpenSim.Region.Framework.Scenes
1247 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 1242 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1248 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 1243 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1249 } 1244 }
1250 item.OwnerChanged = true;
1251 item.CurrentPermissions &= item.NextPermissions; 1245 item.CurrentPermissions &= item.NextPermissions;
1252 item.BasePermissions &= item.NextPermissions; 1246 item.BasePermissions &= item.NextPermissions;
1253 item.EveryonePermissions &= item.NextPermissions; 1247 item.EveryonePermissions &= item.NextPermissions;
1248 item.OwnerChanged = true;
1254 item.PermsMask = 0; 1249 item.PermsMask = 0;
1255 item.PermsGranter = UUID.Zero; 1250 item.PermsGranter = UUID.Zero;
1256 } 1251 }
@@ -1281,9 +1276,57 @@ namespace OpenSim.Region.Framework.Scenes
1281 return true; 1276 return true;
1282 } 1277 }
1283 } 1278 }
1279
1284 return false; 1280 return false;
1285 } 1281 }
1286 1282
1283 /// <summary>
1284 /// Returns the count of scripts in this parts inventory.
1285 /// </summary>
1286 /// <returns></returns>
1287 public int ScriptCount()
1288 {
1289 int count = 0;
1290 Items.LockItemsForRead(true);
1291 foreach (TaskInventoryItem item in m_items.Values)
1292 {
1293 if (item.InvType == (int)InventoryType.LSL)
1294 {
1295 count++;
1296 }
1297 }
1298 Items.LockItemsForRead(false);
1299 return count;
1300 }
1301 /// <summary>
1302 /// Returns the count of running scripts in this parts inventory.
1303 /// </summary>
1304 /// <returns></returns>
1305 public int RunningScriptCount()
1306 {
1307 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1308 if (engines.Length == 0)
1309 return 0;
1310
1311 int count = 0;
1312 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1313
1314 foreach (TaskInventoryItem item in scripts)
1315 {
1316 foreach (IScriptModule engine in engines)
1317 {
1318 if (engine != null)
1319 {
1320 if (engine.GetScriptState(item.ItemID))
1321 {
1322 count++;
1323 }
1324 }
1325 }
1326 }
1327 return count;
1328 }
1329
1287 public List<UUID> GetInventoryList() 1330 public List<UUID> GetInventoryList()
1288 { 1331 {
1289 List<UUID> ret = new List<UUID>(); 1332 List<UUID> ret = new List<UUID>();
@@ -1298,22 +1341,24 @@ namespace OpenSim.Region.Framework.Scenes
1298 { 1341 {
1299 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1342 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1300 1343
1301 lock (m_items) 1344 Items.LockItemsForRead(true);
1302 ret = new List<TaskInventoryItem>(m_items.Values); 1345 ret = new List<TaskInventoryItem>(m_items.Values);
1346 Items.LockItemsForRead(false);
1303 1347
1304 return ret; 1348 return ret;
1305 } 1349 }
1306 1350
1307 public List<TaskInventoryItem> GetInventoryScripts() 1351 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1308 { 1352 {
1309 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1353 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1310 1354
1311 lock (m_items) 1355 Items.LockItemsForRead(true);
1312 { 1356
1313 foreach (TaskInventoryItem item in m_items.Values) 1357 foreach (TaskInventoryItem item in m_items.Values)
1314 if (item.InvType == (int)InventoryType.LSL) 1358 if (item.InvType == (int)type)
1315 ret.Add(item); 1359 ret.Add(item);
1316 } 1360
1361 Items.LockItemsForRead(false);
1317 1362
1318 return ret; 1363 return ret;
1319 } 1364 }
@@ -1335,35 +1380,32 @@ namespace OpenSim.Region.Framework.Scenes
1335 if (engines.Length == 0) // No engine at all 1380 if (engines.Length == 0) // No engine at all
1336 return ret; 1381 return ret;
1337 1382
1338 Items.LockItemsForRead(true); 1383 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1339 foreach (TaskInventoryItem item in m_items.Values) 1384
1385 foreach (TaskInventoryItem item in scripts)
1340 { 1386 {
1341 if (item.InvType == (int)InventoryType.LSL) 1387 foreach (IScriptModule e in engines)
1342 { 1388 {
1343 foreach (IScriptModule e in engines) 1389 if (e != null)
1344 { 1390 {
1345 if (e != null) 1391 string n = e.GetXMLState(item.ItemID);
1392 if (n != String.Empty)
1346 { 1393 {
1347 string n = e.GetXMLState(item.ItemID); 1394 if (oldIDs)
1348 if (n != String.Empty) 1395 {
1396 if (!ret.ContainsKey(item.OldItemID))
1397 ret[item.OldItemID] = n;
1398 }
1399 else
1349 { 1400 {
1350 if (oldIDs) 1401 if (!ret.ContainsKey(item.ItemID))
1351 { 1402 ret[item.ItemID] = n;
1352 if (!ret.ContainsKey(item.OldItemID))
1353 ret[item.OldItemID] = n;
1354 }
1355 else
1356 {
1357 if (!ret.ContainsKey(item.ItemID))
1358 ret[item.ItemID] = n;
1359 }
1360 break;
1361 } 1403 }
1404 break;
1362 } 1405 }
1363 } 1406 }
1364 } 1407 }
1365 } 1408 }
1366 Items.LockItemsForRead(false);
1367 return ret; 1409 return ret;
1368 } 1410 }
1369 1411
@@ -1373,27 +1415,27 @@ namespace OpenSim.Region.Framework.Scenes
1373 if (engines.Length == 0) 1415 if (engines.Length == 0)
1374 return; 1416 return;
1375 1417
1418 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1376 1419
1377 Items.LockItemsForRead(true); 1420 foreach (TaskInventoryItem item in scripts)
1378
1379 foreach (TaskInventoryItem item in m_items.Values)
1380 { 1421 {
1381 if (item.InvType == (int)InventoryType.LSL) 1422 foreach (IScriptModule engine in engines)
1382 { 1423 {
1383 foreach (IScriptModule engine in engines) 1424 if (engine != null)
1384 { 1425 {
1385 if (engine != null) 1426// m_log.DebugFormat(
1386 { 1427// "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}",
1387 if (item.OwnerChanged) 1428// item.Name, item.ItemID, item.OwnerID, item.OwnerChanged);
1388 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); 1429
1389 item.OwnerChanged = false; 1430 engine.ResumeScript(item.ItemID);
1390 engine.ResumeScript(item.ItemID); 1431
1391 } 1432 if (item.OwnerChanged)
1433 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1434
1435 item.OwnerChanged = false;
1392 } 1436 }
1393 } 1437 }
1394 } 1438 }
1395
1396 Items.LockItemsForRead(false);
1397 } 1439 }
1398 } 1440 }
1399} 1441}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a810de2..6feb883 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -45,6 +45,7 @@ using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
45 45
46namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
47{ 47{
48 [Flags]
48 enum ScriptControlled : uint 49 enum ScriptControlled : uint
49 { 50 {
50 CONTROL_ZERO = 0, 51 CONTROL_ZERO = 0,
@@ -76,6 +77,11 @@ namespace OpenSim.Region.Framework.Scenes
76// { 77// {
77// m_log.Debug("[SCENE PRESENCE] Destructor called"); 78// m_log.Debug("[SCENE PRESENCE] Destructor called");
78// } 79// }
80 private void TriggerScenePresenceUpdated()
81 {
82 if (m_scene != null)
83 m_scene.EventManager.TriggerScenePresenceUpdated(this);
84 }
79 85
80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 86 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
81 87
@@ -497,6 +503,7 @@ namespace OpenSim.Region.Framework.Scenes
497 //m_log.DebugFormat( 503 //m_log.DebugFormat(
498 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", 504 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
499 // Scene.RegionInfo.RegionName, Name, m_pos); 505 // Scene.RegionInfo.RegionName, Name, m_pos);
506 TriggerScenePresenceUpdated();
500 } 507 }
501 } 508 }
502 509
@@ -516,6 +523,7 @@ namespace OpenSim.Region.Framework.Scenes
516 return; 523 return;
517 524
518 m_pos = value; 525 m_pos = value;
526 TriggerScenePresenceUpdated();
519 } 527 }
520 } 528 }
521 529
@@ -1086,23 +1094,13 @@ namespace OpenSim.Region.Framework.Scenes
1086 /// <param name="pos"></param> 1094 /// <param name="pos"></param>
1087 public void Teleport(Vector3 pos) 1095 public void Teleport(Vector3 pos)
1088 { 1096 {
1089 bool isFlying = Flying; 1097 TeleportWithMomentum(pos, Vector3.Zero);
1090 RemoveFromPhysicalScene();
1091 Velocity = Vector3.Zero;
1092 CheckLandingPoint(ref pos);
1093 AbsolutePosition = pos;
1094 AddToPhysicalScene(isFlying);
1095
1096 SendTerseUpdateToAllClients();
1097 }
1098
1099 public void TeleportWithMomentum(Vector3 pos)
1100 {
1101 TeleportWithMomentum(pos, null);
1102 } 1098 }
1103 1099
1104 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1100 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
1105 { 1101 {
1102 if (ParentID != (uint)0)
1103 StandUp();
1106 bool isFlying = Flying; 1104 bool isFlying = Flying;
1107 Vector3 vel = Velocity; 1105 Vector3 vel = Velocity;
1108 RemoveFromPhysicalScene(); 1106 RemoveFromPhysicalScene();
@@ -1282,17 +1280,33 @@ namespace OpenSim.Region.Framework.Scenes
1282 1280
1283 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1281 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1284 MakeRootAgent(AbsolutePosition, flying); 1282 MakeRootAgent(AbsolutePosition, flying);
1283 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1284
1285// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1285 1286
1286 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1287 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1287 { 1288 {
1288 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1289 // We cannot sleep here since this would hold up the inbound packet processing thread, as
1290 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
1291 // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete
1292 // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this
1293 // region as the current region, meaning that a close sent before then will fail the teleport.
1294// System.Threading.Thread.Sleep(2000);
1295
1296 m_log.DebugFormat(
1297 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
1298 client.Name, client.AgentId, m_callbackURI);
1299
1289 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); 1300 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1290 m_callbackURI = null; 1301 m_callbackURI = null;
1291 } 1302 }
1303// else
1304// {
1305// m_log.DebugFormat(
1306// "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}",
1307// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
1308// }
1292 1309
1293// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1294
1295 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1296 ValidateAndSendAppearanceAndAgentData(); 1310 ValidateAndSendAppearanceAndAgentData();
1297 1311
1298 // Create child agents in neighbouring regions 1312 // Create child agents in neighbouring regions
@@ -1307,7 +1321,6 @@ namespace OpenSim.Region.Framework.Scenes
1307 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1321 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1308 } 1322 }
1309 1323
1310
1311// m_log.DebugFormat( 1324// m_log.DebugFormat(
1312// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1325// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1313// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1326// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1360,7 +1373,7 @@ namespace OpenSim.Region.Framework.Scenes
1360 { 1373 {
1361// m_log.DebugFormat( 1374// m_log.DebugFormat(
1362// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1375// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1363// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); 1376// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1364 1377
1365 if (IsChildAgent) 1378 if (IsChildAgent)
1366 { 1379 {
@@ -1470,14 +1483,8 @@ namespace OpenSim.Region.Framework.Scenes
1470 } 1483 }
1471 } 1484 }
1472 1485
1473 lock (scriptedcontrols) 1486 uint flagsForScripts = (uint)flags;
1474 { 1487 flags = RemoveIgnoredControls(flags, IgnoredControls);
1475 if (scriptedcontrols.Count > 0)
1476 {
1477 SendControlToScripts((uint)flags);
1478 flags = RemoveIgnoredControls(flags, IgnoredControls);
1479 }
1480 }
1481 1488
1482 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) 1489 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
1483 HandleAgentSitOnGround(); 1490 HandleAgentSitOnGround();
@@ -1491,6 +1498,7 @@ namespace OpenSim.Region.Framework.Scenes
1491 PhysicsActor actor = PhysicsActor; 1498 PhysicsActor actor = PhysicsActor;
1492 if (actor == null) 1499 if (actor == null)
1493 { 1500 {
1501 SendControlsToScripts(flagsForScripts);
1494 return; 1502 return;
1495 } 1503 }
1496 1504
@@ -1570,7 +1578,7 @@ namespace OpenSim.Region.Framework.Scenes
1570 MovementFlag |= (byte)nudgehack; 1578 MovementFlag |= (byte)nudgehack;
1571 } 1579 }
1572 1580
1573// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 1581 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1574 MovementFlag += (byte)(uint)DCF; 1582 MovementFlag += (byte)(uint)DCF;
1575 update_movementflag = true; 1583 update_movementflag = true;
1576 } 1584 }
@@ -1583,7 +1591,7 @@ namespace OpenSim.Region.Framework.Scenes
1583 && ((MovementFlag & (byte)nudgehack) == nudgehack)) 1591 && ((MovementFlag & (byte)nudgehack) == nudgehack))
1584 ) // This or is for Nudge forward 1592 ) // This or is for Nudge forward
1585 { 1593 {
1586// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 1594 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
1587 MovementFlag -= ((byte)(uint)DCF); 1595 MovementFlag -= ((byte)(uint)DCF);
1588 update_movementflag = true; 1596 update_movementflag = true;
1589 1597
@@ -1664,11 +1672,14 @@ namespace OpenSim.Region.Framework.Scenes
1664// } 1672// }
1665// } 1673// }
1666 1674
1667// if (update_movementflag && ParentID == 0) 1675 if (update_movementflag && ParentID == 0)
1668// Animator.UpdateMovementAnimations(); 1676 Animator.UpdateMovementAnimations();
1677
1678 SendControlsToScripts(flagsForScripts);
1669 } 1679 }
1670 1680
1671 m_scene.EventManager.TriggerOnClientMovement(this); 1681 m_scene.EventManager.TriggerOnClientMovement(this);
1682 TriggerScenePresenceUpdated();
1672 } 1683 }
1673 1684
1674 /// <summary> 1685 /// <summary>
@@ -2611,6 +2622,7 @@ namespace OpenSim.Region.Framework.Scenes
2611 2622
2612 m_scene.ForEachClient(SendTerseUpdateToClient); 2623 m_scene.ForEachClient(SendTerseUpdateToClient);
2613 } 2624 }
2625 TriggerScenePresenceUpdated();
2614 } 2626 }
2615 2627
2616 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2628 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -2689,7 +2701,7 @@ namespace OpenSim.Region.Framework.Scenes
2689 // If we are using the the cached appearance then send it out to everyone 2701 // If we are using the the cached appearance then send it out to everyone
2690 if (cachedappearance) 2702 if (cachedappearance)
2691 { 2703 {
2692 m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2704 m_log.DebugFormat("[SCENE PRESENCE]: baked textures are in the cache for {0}", Name);
2693 2705
2694 // If the avatars baked textures are all in the cache, then we have a 2706 // If the avatars baked textures are all in the cache, then we have a
2695 // complete appearance... send it out, if not, then we'll send it when 2707 // complete appearance... send it out, if not, then we'll send it when
@@ -3094,8 +3106,8 @@ namespace OpenSim.Region.Framework.Scenes
3094 x = x / Constants.RegionSize; 3106 x = x / Constants.RegionSize;
3095 y = y / Constants.RegionSize; 3107 y = y / Constants.RegionSize;
3096 3108
3097 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3109// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3098 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3110// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3099 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) 3111 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3100 { 3112 {
3101 byebyeRegions.Add(handle); 3113 byebyeRegions.Add(handle);
@@ -3152,7 +3164,7 @@ namespace OpenSim.Region.Framework.Scenes
3152 3164
3153 public void ChildAgentDataUpdate(AgentData cAgentData) 3165 public void ChildAgentDataUpdate(AgentData cAgentData)
3154 { 3166 {
3155 //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); 3167// m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName);
3156 if (!IsChildAgent) 3168 if (!IsChildAgent)
3157 return; 3169 return;
3158 3170
@@ -3296,6 +3308,9 @@ namespace OpenSim.Region.Framework.Scenes
3296 m_originRegionID = cAgent.RegionID; 3308 m_originRegionID = cAgent.RegionID;
3297 3309
3298 m_callbackURI = cAgent.CallbackURI; 3310 m_callbackURI = cAgent.CallbackURI;
3311// m_log.DebugFormat(
3312// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
3313// Name, m_scene.RegionInfo.RegionName, m_callbackURI);
3299 3314
3300 m_pos = cAgent.Position; 3315 m_pos = cAgent.Position;
3301 m_velocity = cAgent.Velocity; 3316 m_velocity = cAgent.Velocity;
@@ -3397,6 +3412,7 @@ namespace OpenSim.Region.Framework.Scenes
3397 Velocity = force; 3412 Velocity = force;
3398 3413
3399 m_forceToApply = null; 3414 m_forceToApply = null;
3415 TriggerScenePresenceUpdated();
3400 } 3416 }
3401 } 3417 }
3402 3418
@@ -3504,23 +3520,53 @@ namespace OpenSim.Region.Framework.Scenes
3504 3520
3505 RaiseCollisionScriptEvents(coldata); 3521 RaiseCollisionScriptEvents(coldata);
3506 3522
3507 if (Invulnerable || GodLevel >= 200) 3523 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3524 if (Invulnerable || GodLevel > 0)
3508 return; 3525 return;
3509 3526
3527 // The following may be better in the ICombatModule
3528 // probably tweaking of the values for ground and normal prim collisions will be needed
3510 float starthealth = Health; 3529 float starthealth = Health;
3511 uint killerObj = 0; 3530 uint killerObj = 0;
3531 SceneObjectPart part = null;
3512 foreach (uint localid in coldata.Keys) 3532 foreach (uint localid in coldata.Keys)
3513 { 3533 {
3514 SceneObjectPart part = Scene.GetSceneObjectPart(localid); 3534 if (localid == 0)
3515 3535 {
3516 if (part != null && part.ParentGroup.Damage != -1.0f) 3536 part = null;
3517 Health -= part.ParentGroup.Damage; 3537 }
3518 else 3538 else
3519 { 3539 {
3520 if (coldata[localid].PenetrationDepth >= 0.10f) 3540 part = Scene.GetSceneObjectPart(localid);
3541 }
3542 if (part != null)
3543 {
3544 // Ignore if it has been deleted or volume detect
3545 if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect)
3546 {
3547 if (part.ParentGroup.Damage > 0.0f)
3548 {
3549 // Something with damage...
3550 Health -= part.ParentGroup.Damage;
3551 part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false);
3552 }
3553 else
3554 {
3555 // An ordinary prim
3556 if (coldata[localid].PenetrationDepth >= 0.10f)
3557 Health -= coldata[localid].PenetrationDepth * 5.0f;
3558 }
3559 }
3560 }
3561 else
3562 {
3563 // 0 is the ground
3564 // what about collisions with other avatars?
3565 if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f)
3521 Health -= coldata[localid].PenetrationDepth * 5.0f; 3566 Health -= coldata[localid].PenetrationDepth * 5.0f;
3522 } 3567 }
3523 3568
3569
3524 if (Health <= 0.0f) 3570 if (Health <= 0.0f)
3525 { 3571 {
3526 if (localid != 0) 3572 if (localid != 0)
@@ -3536,7 +3582,16 @@ namespace OpenSim.Region.Framework.Scenes
3536 ControllingClient.SendHealth(Health); 3582 ControllingClient.SendHealth(Health);
3537 } 3583 }
3538 if (Health <= 0) 3584 if (Health <= 0)
3585 {
3539 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3586 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3587 }
3588 if (starthealth == Health && Health < 100.0f)
3589 {
3590 Health += 0.03f;
3591 if (Health > 100.0f)
3592 Health = 100.0f;
3593 ControllingClient.SendHealth(Health);
3594 }
3540 } 3595 }
3541 } 3596 }
3542 3597
@@ -3548,7 +3603,7 @@ namespace OpenSim.Region.Framework.Scenes
3548 3603
3549 public void Close() 3604 public void Close()
3550 { 3605 {
3551 if (!IsChildAgent) 3606 if (!IsChildAgent && m_scene.AttachmentsModule != null)
3552 m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); 3607 m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false);
3553 3608
3554 // Clear known regions 3609 // Clear known regions
@@ -3618,6 +3673,63 @@ namespace OpenSim.Region.Framework.Scenes
3618 return m_attachments.Count > 0; 3673 return m_attachments.Count > 0;
3619 } 3674 }
3620 3675
3676 /// <summary>
3677 /// Returns the total count of scripts in all parts inventories.
3678 /// </summary>
3679 public int ScriptCount()
3680 {
3681 int count = 0;
3682 lock (m_attachments)
3683 {
3684 foreach (SceneObjectGroup gobj in m_attachments)
3685 {
3686 if (gobj != null)
3687 {
3688 count += gobj.ScriptCount();
3689 }
3690 }
3691 }
3692 return count;
3693 }
3694
3695 /// <summary>
3696 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3697 /// </summary>
3698 public float ScriptExecutionTime()
3699 {
3700 float time = 0.0f;
3701 lock (m_attachments)
3702 {
3703 foreach (SceneObjectGroup gobj in m_attachments)
3704 {
3705 if (gobj != null)
3706 {
3707 time += gobj.ScriptExecutionTime();
3708 }
3709 }
3710 }
3711 return time;
3712 }
3713
3714 /// <summary>
3715 /// Returns the total count of running scripts in all parts.
3716 /// </summary>
3717 public int RunningScriptCount()
3718 {
3719 int count = 0;
3720 lock (m_attachments)
3721 {
3722 foreach (SceneObjectGroup gobj in m_attachments)
3723 {
3724 if (gobj != null)
3725 {
3726 count += gobj.RunningScriptCount();
3727 }
3728 }
3729 }
3730 return count;
3731 }
3732
3621 public bool HasScriptedAttachments() 3733 public bool HasScriptedAttachments()
3622 { 3734 {
3623 lock (m_attachments) 3735 lock (m_attachments)
@@ -3835,77 +3947,92 @@ namespace OpenSim.Region.Framework.Scenes
3835 } 3947 }
3836 } 3948 }
3837 3949
3838 internal void SendControlToScripts(uint flags) 3950 private void SendControlsToScripts(uint flags)
3839 { 3951 {
3840 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3952 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3841 3953 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3842 if (MouseDown) 3954 lock (scriptedcontrols)
3843 { 3955 {
3844 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3956 if (scriptedcontrols.Count <= 0)
3845 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) 3957 return;
3958
3959 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
3960
3961 if (MouseDown)
3962 {
3963 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
3964 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
3965 {
3966 allflags = ScriptControlled.CONTROL_ZERO;
3967 MouseDown = true;
3968 }
3969 }
3970
3971 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
3846 { 3972 {
3847 allflags = ScriptControlled.CONTROL_ZERO; 3973 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3848 MouseDown = true; 3974 MouseDown = true;
3849 } 3975 }
3850 } 3976
3977 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
3978 {
3979 allflags |= ScriptControlled.CONTROL_LBUTTON;
3980 MouseDown = true;
3981 }
3982
3983 // find all activated controls, whether the scripts are interested in them or not
3984 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
3985 {
3986 allflags |= ScriptControlled.CONTROL_FWD;
3987 }
3988
3989 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3990 {
3991 allflags |= ScriptControlled.CONTROL_BACK;
3992 }
3993
3994 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3995 {
3996 allflags |= ScriptControlled.CONTROL_UP;
3997 }
3998
3999 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
4000 {
4001 allflags |= ScriptControlled.CONTROL_DOWN;
4002 }
3851 4003
3852 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) 4004 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3853 { 4005 {
3854 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 4006 allflags |= ScriptControlled.CONTROL_LEFT;
3855 MouseDown = true; 4007 }
3856 } 4008
3857 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) 4009 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3858 { 4010 {
3859 allflags |= ScriptControlled.CONTROL_LBUTTON; 4011 allflags |= ScriptControlled.CONTROL_RIGHT;
3860 MouseDown = true; 4012 }
3861 } 4013
4014 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
4015 {
4016 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
4017 }
4018
4019 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
4020 {
4021 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
4022 }
3862 4023
3863 // find all activated controls, whether the scripts are interested in them or not 4024 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3864 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 4025 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3865 {
3866 allflags |= ScriptControlled.CONTROL_FWD;
3867 }
3868 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3869 {
3870 allflags |= ScriptControlled.CONTROL_BACK;
3871 }
3872 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3873 {
3874 allflags |= ScriptControlled.CONTROL_UP;
3875 }
3876 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3877 {
3878 allflags |= ScriptControlled.CONTROL_DOWN;
3879 }
3880 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3881 {
3882 allflags |= ScriptControlled.CONTROL_LEFT;
3883 }
3884 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3885 {
3886 allflags |= ScriptControlled.CONTROL_RIGHT;
3887 }
3888 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3889 {
3890 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3891 }
3892 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3893 {
3894 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3895 }
3896 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3897 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3898 {
3899 lock (scriptedcontrols)
3900 { 4026 {
3901 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 4027 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3902 { 4028 {
3903 UUID scriptUUID = kvp.Key; 4029 UUID scriptUUID = kvp.Key;
3904 ScriptControllers scriptControlData = kvp.Value; 4030 ScriptControllers scriptControlData = kvp.Value;
3905 4031
3906 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 4032 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3907 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle 4033 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
3908 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 4034 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
4035
3909 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 4036 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3910 { 4037 {
3911 // only send if still pressed or just changed 4038 // only send if still pressed or just changed
@@ -3913,9 +4040,9 @@ namespace OpenSim.Region.Framework.Scenes
3913 } 4040 }
3914 } 4041 }
3915 } 4042 }
4043
4044 LastCommands = allflags;
3916 } 4045 }
3917
3918 LastCommands = allflags;
3919 } 4046 }
3920 4047
3921 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 4048 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
@@ -3995,7 +4122,7 @@ namespace OpenSim.Region.Framework.Scenes
3995 land.LandData.UserLocation != Vector3.Zero && 4122 land.LandData.UserLocation != Vector3.Zero &&
3996 land.LandData.OwnerID != m_uuid && 4123 land.LandData.OwnerID != m_uuid &&
3997 (!m_scene.Permissions.IsGod(m_uuid)) && 4124 (!m_scene.Permissions.IsGod(m_uuid)) &&
3998 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) 4125 (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)))
3999 { 4126 {
4000 float curr = Vector3.Distance(AbsolutePosition, pos); 4127 float curr = Vector3.Distance(AbsolutePosition, pos);
4001 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) 4128 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
@@ -4009,13 +4136,13 @@ namespace OpenSim.Region.Framework.Scenes
4009 { 4136 {
4010 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == 4137 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
4011 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || 4138 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
4012 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || 4139 (m_scene.TelehubAllowLandmarks == true ? false : ((m_teleportFlags & TeleportFlags.ViaLandmark) != 0 )) ||
4013 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4140 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4014 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) 4141 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
4015 { 4142 {
4016 if (GodLevel < 200 && 4143 if (GodLevel < 200 &&
4017 ((!m_scene.Permissions.IsGod(m_uuid) && 4144 ((!m_scene.Permissions.IsGod(m_uuid) &&
4018 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4145 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4019 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4146 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4020 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4147 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4021 { 4148 {
@@ -4023,28 +4150,92 @@ namespace OpenSim.Region.Framework.Scenes
4023 if (spawnPoints.Length == 0) 4150 if (spawnPoints.Length == 0)
4024 return; 4151 return;
4025 4152
4026 float distance = 9999; 4153 int index;
4027 int closest = -1; 4154 bool selected = false;
4028 4155
4029 for (int i = 0 ; i < spawnPoints.Length ; i++) 4156 switch (m_scene.SpawnPointRouting)
4030 { 4157 {
4031 Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4158 case "random":
4032 Vector3 offset = spawnPosition - pos;
4033 float d = Vector3.Mag(offset);
4034 if (d >= distance)
4035 continue;
4036 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4037 if (land == null)
4038 continue;
4039 if (land.IsEitherBannedOrRestricted(UUID))
4040 continue;
4041 distance = d;
4042 closest = i;
4043 }
4044 if (closest == -1)
4045 return;
4046 4159
4047 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4160 do
4161 {
4162 index = Util.RandomClass.Next(spawnPoints.Length - 1);
4163
4164 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4165 telehub.AbsolutePosition,
4166 telehub.GroupRotation
4167 );
4168 // SpawnPoint sp = spawnPoints[index];
4169
4170 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4171 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4172 selected = false;
4173 else
4174 selected = true;
4175
4176 } while ( selected == false);
4177
4178 pos = spawnPoints[index].GetLocation(
4179 telehub.AbsolutePosition,
4180 telehub.GroupRotation
4181 );
4182 return;
4183
4184 case "sequence":
4185
4186 do
4187 {
4188 index = m_scene.SpawnPoint();
4189
4190 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4191 telehub.AbsolutePosition,
4192 telehub.GroupRotation
4193 );
4194 // SpawnPoint sp = spawnPoints[index];
4195
4196 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4197 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4198 selected = false;
4199 else
4200 selected = true;
4201
4202 } while (selected == false);
4203
4204 pos = spawnPoints[index].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4205 ;
4206 return;
4207
4208 default:
4209 case "closest":
4210
4211 float distance = 9999;
4212 int closest = -1;
4213
4214 for (int i = 0; i < spawnPoints.Length; i++)
4215 {
4216 Vector3 spawnPosition = spawnPoints[i].GetLocation(
4217 telehub.AbsolutePosition,
4218 telehub.GroupRotation
4219 );
4220 Vector3 offset = spawnPosition - pos;
4221 float d = Vector3.Mag(offset);
4222 if (d >= distance)
4223 continue;
4224 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4225 if (land == null)
4226 continue;
4227 if (land.IsEitherBannedOrRestricted(UUID))
4228 continue;
4229 distance = d;
4230 closest = i;
4231 }
4232 if (closest == -1)
4233 return;
4234
4235 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4236 return;
4237
4238 }
4048 } 4239 }
4049 } 4240 }
4050 } 4241 }
@@ -4089,7 +4280,7 @@ namespace OpenSim.Region.Framework.Scenes
4089 GodLevel < 200 && 4280 GodLevel < 200 &&
4090 ((land.LandData.OwnerID != m_uuid && 4281 ((land.LandData.OwnerID != m_uuid &&
4091 !m_scene.Permissions.IsGod(m_uuid) && 4282 !m_scene.Permissions.IsGod(m_uuid) &&
4092 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4283 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4093 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4284 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4094 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4285 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4095 { 4286 {
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
index 55455cc..a4f730d 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
@@ -47,14 +47,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
47 /// </remarks> 47 /// </remarks>
48 public class CoalescedSceneObjectsSerializer 48 public class CoalescedSceneObjectsSerializer
49 { 49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 /// <summary> 52 /// <summary>
53 /// Serialize coalesced objects to Xml 53 /// Serialize coalesced objects to Xml
54 /// </summary> 54 /// </summary>
55 /// <param name="coa"></param> 55 /// <param name="coa"></param>
56 /// <param name="doScriptStates">
57 /// If true then serialize script states. This will halt any running scripts
58 /// </param>
56 /// <returns></returns> 59 /// <returns></returns>
57 public static string ToXml(CoalescedSceneObjects coa) 60 public static string ToXml(CoalescedSceneObjects coa)
61 {
62 return ToXml(coa, true);
63 }
64
65 /// <summary>
66 /// Serialize coalesced objects to Xml
67 /// </summary>
68 /// <param name="coa"></param>
69 /// <param name="doScriptStates">
70 /// If true then serialize script states. This will halt any running scripts
71 /// </param>
72 /// <returns></returns>
73 public static string ToXml(CoalescedSceneObjects coa, bool doScriptStates)
58 { 74 {
59 using (StringWriter sw = new StringWriter()) 75 using (StringWriter sw = new StringWriter())
60 { 76 {
@@ -91,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
91 writer.WriteAttributeString("offsety", offsets[i].Y.ToString()); 107 writer.WriteAttributeString("offsety", offsets[i].Y.ToString());
92 writer.WriteAttributeString("offsetz", offsets[i].Z.ToString()); 108 writer.WriteAttributeString("offsetz", offsets[i].Z.ToString());
93 109
94 SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, true); 110 SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, doScriptStates);
95 111
96 writer.WriteEndElement(); // SceneObjectGroup 112 writer.WriteEndElement(); // SceneObjectGroup
97 } 113 }
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 151eba2..e223f47 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1538,51 +1538,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1538 } 1538 }
1539 } 1539 }
1540 1540
1541 //////// Read /////////
1542 public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
1543 {
1544 reader.Read();
1545 reader.ReadStartElement("SceneObjectGroup");
1546 SceneObjectPart root = Xml2ToSOP(reader);
1547 if (root != null)
1548 sog.SetRootPart(root);
1549 else
1550 {
1551 return false;
1552 }
1553
1554 if (sog.UUID == UUID.Zero)
1555 sog.UUID = sog.RootPart.UUID;
1556
1557 reader.Read(); // OtherParts
1558
1559 while (!reader.EOF)
1560 {
1561 switch (reader.NodeType)
1562 {
1563 case XmlNodeType.Element:
1564 if (reader.Name == "SceneObjectPart")
1565 {
1566 SceneObjectPart child = Xml2ToSOP(reader);
1567 if (child != null)
1568 sog.AddPart(child);
1569 }
1570 else
1571 {
1572 //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
1573 reader.Read();
1574 }
1575 break;
1576 case XmlNodeType.EndElement:
1577 default:
1578 reader.Read();
1579 break;
1580 }
1581
1582 }
1583 return true;
1584 }
1585
1586 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) 1541 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
1587 { 1542 {
1588 SceneObjectPart obj = new SceneObjectPart(); 1543 SceneObjectPart obj = new SceneObjectPart();
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index d214eba..a3485d2 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -223,50 +223,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
223 223
224 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) 224 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
225 { 225 {
226 XmlDocument doc = new XmlDocument(); 226 return SceneObjectSerializer.FromXml2Format(xmlString);
227 XmlNode rootNode;
228
229 XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
230 reader.WhitespaceHandling = WhitespaceHandling.None;
231 doc.Load(reader);
232 reader.Close();
233 rootNode = doc.FirstChild;
234
235 // This is to deal with neighbouring regions that are still surrounding the group xml with the <scene>
236 // tag. It should be possible to remove the first part of this if statement once we go past 0.5.9 (or
237 // when some other changes forces all regions to upgrade).
238 // This might seem rather pointless since prim crossing from this revision to an earlier revision remains
239 // broken. But it isn't much work to accomodate the old format here.
240 if (rootNode.LocalName.Equals("scene"))
241 {
242 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
243 {
244 // There is only ever one prim. This oddity should be removeable post 0.5.9
245 //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
246 using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml)))
247 {
248 SceneObjectGroup obj = new SceneObjectGroup();
249 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
250 return obj;
251
252 return null;
253 }
254 }
255
256 return null;
257 }
258 else
259 {
260 //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
261 using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml)))
262 {
263 SceneObjectGroup obj = new SceneObjectGroup();
264 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
265 return obj;
266
267 return null;
268 }
269 }
270 } 227 }
271 228
272 /// <summary> 229 /// <summary>
@@ -307,8 +264,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
307 ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); 264 ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
308 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 265 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
309 { 266 {
310 SceneObjectGroup obj = CreatePrimFromXml2(scene, aPrimNode.OuterXml); 267 SceneObjectGroup obj = DeserializeGroupFromXml2(aPrimNode.OuterXml);
311 if (obj != null && startScripts) 268 if (startScripts)
312 sceneObjects.Add(obj); 269 sceneObjects.Add(obj);
313 } 270 }
314 271
@@ -319,27 +276,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
319 } 276 }
320 } 277 }
321 278
322 /// <summary>
323 /// Create a prim from the xml2 representation.
324 /// </summary>
325 /// <param name="scene"></param>
326 /// <param name="xmlData"></param>
327 /// <returns>The scene object created. null if the scene object already existed</returns>
328 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
329 {
330 //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
331 using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData)))
332 {
333 SceneObjectGroup obj = new SceneObjectGroup();
334 SceneObjectSerializer.Xml2ToSOG(reader, obj);
335
336 if (scene.AddRestoredSceneObject(obj, true, false))
337 return obj;
338 else
339 return null;
340 }
341 }
342
343 #endregion 279 #endregion
344 } 280 }
345} 281} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index a4afd47..18e6ece 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -26,7 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29//using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Timers; 30using System.Timers;
31using OpenMetaverse.Packets; 31using OpenMetaverse.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
@@ -35,10 +35,18 @@ using OpenSim.Region.Framework.Interfaces;
35 35
36namespace OpenSim.Region.Framework.Scenes 36namespace OpenSim.Region.Framework.Scenes
37{ 37{
38 /// <summary>
39 /// Collect statistics from the scene to send to the client and for access by other monitoring tools.
40 /// </summary>
41 /// <remarks>
42 /// FIXME: This should be a monitoring region module
43 /// </remarks>
38 public class SimStatsReporter 44 public class SimStatsReporter
39 { 45 {
40// private static readonly log4net.ILog m_log 46 private static readonly log4net.ILog m_log
41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 47 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
48
49 public const string LastReportedObjectUpdateStatName = "LastReportedObjectUpdates";
42 50
43 public delegate void SendStatResult(SimStats stats); 51 public delegate void SendStatResult(SimStats stats);
44 52
@@ -48,10 +56,17 @@ namespace OpenSim.Region.Framework.Scenes
48 56
49 public event YourStatsAreWrong OnStatsIncorrect; 57 public event YourStatsAreWrong OnStatsIncorrect;
50 58
51 private SendStatResult handlerSendStatResult = null; 59 private SendStatResult handlerSendStatResult;
52 60
53 private YourStatsAreWrong handlerStatsIncorrect = null; 61 private YourStatsAreWrong handlerStatsIncorrect;
54 62
63 /// <summary>
64 /// These are the IDs of stats sent in the StatsPacket to the viewer.
65 /// </summary>
66 /// <remarks>
67 /// Some of these are not relevant to OpenSimulator since it is architected differently to other simulators
68 /// (e.g. script instructions aren't executed as part of the frame loop so 'script time' is tricky).
69 /// </remarks>
55 public enum Stats : uint 70 public enum Stats : uint
56 { 71 {
57 TimeDilation = 0, 72 TimeDilation = 0,
@@ -75,20 +90,20 @@ namespace OpenSim.Region.Framework.Scenes
75 OutPacketsPerSecond = 18, 90 OutPacketsPerSecond = 18,
76 PendingDownloads = 19, 91 PendingDownloads = 19,
77 PendingUploads = 20, 92 PendingUploads = 20,
78 VirtualSizeKB = 21, 93 VirtualSizeKb = 21,
79 ResidentSizeKB = 22, 94 ResidentSizeKb = 22,
80 PendingLocalUploads = 23, 95 PendingLocalUploads = 23,
81 UnAckedBytes = 24, 96 UnAckedBytes = 24,
82 PhysicsPinnedTasks = 25, 97 PhysicsPinnedTasks = 25,
83 PhysicsLODTasks = 26, 98 PhysicsLodTasks = 26,
84 PhysicsStepMS = 27, 99 SimPhysicsStepMs = 27,
85 PhysicsShapeMS = 28, 100 SimPhysicsShapeMs = 28,
86 PhysicsOtherMS = 29, 101 SimPhysicsOtherMs = 29,
87 PhysicsMemory = 30, 102 SimPhysicsMemory = 30,
88 ScriptEPS = 31, 103 ScriptEps = 31,
89 SimSpareTime = 32, 104 SimSpareMs = 32,
90 SimSleepTime = 33, 105 SimSleepMs = 33,
91 IOPumpTime = 34 106 SimIoPumpTime = 34
92 } 107 }
93 108
94 /// <summary> 109 /// <summary>
@@ -113,11 +128,24 @@ namespace OpenSim.Region.Framework.Scenes
113 get { return lastReportedSimStats; } 128 get { return lastReportedSimStats; }
114 } 129 }
115 130
131 /// <summary>
132 /// Extra sim statistics that are used by monitors but not sent to the client.
133 /// </summary>
134 /// <value>
135 /// The keys are the stat names.
136 /// </value>
137 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>();
138
116 // Sending a stats update every 3 seconds- 139 // Sending a stats update every 3 seconds-
117 private int statsUpdatesEveryMS = 3000; 140 private int m_statsUpdatesEveryMS = 3000;
118 private float statsUpdateFactor = 0; 141 private float m_statsUpdateFactor;
119 private float m_timeDilation = 0; 142 private float m_timeDilation;
120 private int m_fps = 0; 143 private int m_fps;
144
145 /// <summary>
146 /// Number of the last frame on which we processed a stats udpate.
147 /// </summary>
148 private uint m_lastUpdateFrame;
121 149
122 /// <summary> 150 /// <summary>
123 /// Our nominal fps target, as expected in fps stats when a sim is running normally. 151 /// Our nominal fps target, as expected in fps stats when a sim is running normally.
@@ -135,43 +163,42 @@ namespace OpenSim.Region.Framework.Scenes
135 private float m_reportedFpsCorrectionFactor = 5; 163 private float m_reportedFpsCorrectionFactor = 5;
136 164
137 // saved last reported value so there is something available for llGetRegionFPS 165 // saved last reported value so there is something available for llGetRegionFPS
138 private float lastReportedSimFPS = 0; 166 private float lastReportedSimFPS;
139 private float[] lastReportedSimStats = new float[23]; 167 private float[] lastReportedSimStats = new float[22];
140 private float m_pfps = 0; 168 private float m_pfps;
141 169
142 /// <summary> 170 /// <summary>
143 /// Number of agent updates requested in this stats cycle 171 /// Number of agent updates requested in this stats cycle
144 /// </summary> 172 /// </summary>
145 private int m_agentUpdates = 0; 173 private int m_agentUpdates;
146 174
147 /// <summary> 175 /// <summary>
148 /// Number of object updates requested in this stats cycle 176 /// Number of object updates requested in this stats cycle
149 /// </summary> 177 /// </summary>
150 private int m_objectUpdates; 178 private int m_objectUpdates;
151 179
152 private int m_frameMS = 0; 180 private int m_frameMS;
153 private int m_netMS = 0; 181 private int m_spareMS;
154 private int m_agentMS = 0; 182 private int m_netMS;
155 private int m_physicsMS = 0; 183 private int m_agentMS;
156 private int m_imageMS = 0; 184 private int m_physicsMS;
157 private int m_otherMS = 0; 185 private int m_imageMS;
158 private int m_sleeptimeMS = 0; 186 private int m_otherMS;
159
160 187
161//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 188//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
162//Ckrinke private int m_scriptMS = 0; 189//Ckrinke private int m_scriptMS = 0;
163 190
164 private int m_rootAgents = 0; 191 private int m_rootAgents;
165 private int m_childAgents = 0; 192 private int m_childAgents;
166 private int m_numPrim = 0; 193 private int m_numPrim;
167 private int m_inPacketsPerSecond = 0; 194 private int m_inPacketsPerSecond;
168 private int m_outPacketsPerSecond = 0; 195 private int m_outPacketsPerSecond;
169 private int m_activePrim = 0; 196 private int m_activePrim;
170 private int m_unAckedBytes = 0; 197 private int m_unAckedBytes;
171 private int m_pendingDownloads = 0; 198 private int m_pendingDownloads;
172 private int m_pendingUploads = 0; 199 private int m_pendingUploads = 0; // FIXME: Not currently filled in
173 private int m_activeScripts = 0; 200 private int m_activeScripts;
174 private int m_scriptLinesPerSecond = 0; 201 private int m_scriptLinesPerSecond;
175 202
176 private int m_objectCapacity = 45000; 203 private int m_objectCapacity = 45000;
177 204
@@ -187,13 +214,13 @@ namespace OpenSim.Region.Framework.Scenes
187 { 214 {
188 m_scene = scene; 215 m_scene = scene;
189 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; 216 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps;
190 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 217 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
191 ReportingRegion = scene.RegionInfo; 218 ReportingRegion = scene.RegionInfo;
192 219
193 m_objectCapacity = scene.RegionInfo.ObjectCapacity; 220 m_objectCapacity = scene.RegionInfo.ObjectCapacity;
194 m_report.AutoReset = true; 221 m_report.AutoReset = true;
195 m_report.Interval = statsUpdatesEveryMS; 222 m_report.Interval = m_statsUpdatesEveryMS;
196 m_report.Elapsed += statsHeartBeat; 223 m_report.Elapsed += TriggerStatsHeartbeat;
197 m_report.Enabled = true; 224 m_report.Enabled = true;
198 225
199 if (StatsManager.SimExtraStats != null) 226 if (StatsManager.SimExtraStats != null)
@@ -202,20 +229,38 @@ namespace OpenSim.Region.Framework.Scenes
202 229
203 public void Close() 230 public void Close()
204 { 231 {
205 m_report.Elapsed -= statsHeartBeat; 232 m_report.Elapsed -= TriggerStatsHeartbeat;
206 m_report.Close(); 233 m_report.Close();
207 } 234 }
208 235
236 /// <summary>
237 /// Sets the number of milliseconds between stat updates.
238 /// </summary>
239 /// <param name='ms'></param>
209 public void SetUpdateMS(int ms) 240 public void SetUpdateMS(int ms)
210 { 241 {
211 statsUpdatesEveryMS = ms; 242 m_statsUpdatesEveryMS = ms;
212 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 243 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
213 m_report.Interval = statsUpdatesEveryMS; 244 m_report.Interval = m_statsUpdatesEveryMS;
245 }
246
247 private void TriggerStatsHeartbeat(object sender, EventArgs args)
248 {
249 try
250 {
251 statsHeartBeat(sender, args);
252 }
253 catch (Exception e)
254 {
255 m_log.Warn(string.Format(
256 "[SIM STATS REPORTER] Update for {0} failed with exception ",
257 m_scene.RegionInfo.RegionName), e);
258 }
214 } 259 }
215 260
216 private void statsHeartBeat(object sender, EventArgs e) 261 private void statsHeartBeat(object sender, EventArgs e)
217 { 262 {
218 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; 263 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
219 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 264 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
220 265
221 // Know what's not thread safe in Mono... modifying timers. 266 // Know what's not thread safe in Mono... modifying timers.
@@ -242,7 +287,7 @@ namespace OpenSim.Region.Framework.Scenes
242 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 287 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
243 288
244 // save the reported value so there is something available for llGetRegionFPS 289 // save the reported value so there is something available for llGetRegionFPS
245 lastReportedSimFPS = reportedFPS / statsUpdateFactor; 290 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
246 291
247 float physfps = ((m_pfps / 1000)); 292 float physfps = ((m_pfps / 1000));
248 293
@@ -253,7 +298,6 @@ namespace OpenSim.Region.Framework.Scenes
253 physfps = 0; 298 physfps = 0;
254 299
255#endregion 300#endregion
256 float factor = 1 / statsUpdateFactor;
257 if (reportedFPS <= 0) 301 if (reportedFPS <= 0)
258 reportedFPS = 1; 302 reportedFPS = 1;
259 303
@@ -264,32 +308,38 @@ namespace OpenSim.Region.Framework.Scenes
264 float targetframetime = 1100.0f / (float)m_nominalReportedFps; 308 float targetframetime = 1100.0f / (float)m_nominalReportedFps;
265 309
266 float sparetime; 310 float sparetime;
267 float sleeptime;
268 if (TotalFrameTime > targetframetime) 311 if (TotalFrameTime > targetframetime)
269 { 312 {
270 sparetime = 0; 313 sparetime = 0;
271 sleeptime = 0;
272 }
273 else
274 {
275 sparetime = m_frameMS - m_physicsMS - m_agentMS;
276 sparetime *= perframe;
277 if (sparetime < 0)
278 sparetime = 0;
279 else if (sparetime > TotalFrameTime)
280 sparetime = TotalFrameTime;
281 sleeptime = m_sleeptimeMS * perframe;
282 } 314 }
315
316 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
317 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
318 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
319 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
320 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
321
322 // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code
323 // so that stat numbers are always consistent.
324 CheckStatSanity();
283 325
284 // other MS is actually simulation time 326 // other MS is actually simulation time
285 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; 327 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
286 // m_imageMS m_netMS are not included in m_frameMS 328 // m_imageMS m_netMS are not included in m_frameMS
287 329
288 m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; 330 m_otherMS = m_frameMS - m_physicsMS - m_agentMS;
289 if (m_otherMS < 0) 331 if (m_otherMS < 0)
290 m_otherMS = 0; 332 m_otherMS = 0;
291 333
292 for (int i = 0; i < 23; i++) 334 uint thisFrame = m_scene.Frame;
335 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
336 m_lastUpdateFrame = thisFrame;
337
338 // Avoid div-by-zero if somehow we've not updated any frames.
339 if (framesUpdated == 0)
340 framesUpdated = 1;
341
342 for (int i = 0; i < 22; i++)
293 { 343 {
294 sb[i] = new SimStatsPacket.StatBlock(); 344 sb[i] = new SimStatsPacket.StatBlock();
295 } 345 }
@@ -298,13 +348,13 @@ namespace OpenSim.Region.Framework.Scenes
298 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 348 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
299 349
300 sb[1].StatID = (uint) Stats.SimFPS; 350 sb[1].StatID = (uint) Stats.SimFPS;
301 sb[1].StatValue = reportedFPS / statsUpdateFactor; 351 sb[1].StatValue = reportedFPS / m_statsUpdateFactor;
302 352
303 sb[2].StatID = (uint) Stats.PhysicsFPS; 353 sb[2].StatID = (uint) Stats.PhysicsFPS;
304 sb[2].StatValue = physfps / statsUpdateFactor; 354 sb[2].StatValue = physfps / m_statsUpdateFactor;
305 355
306 sb[3].StatID = (uint) Stats.AgentUpdates; 356 sb[3].StatID = (uint) Stats.AgentUpdates;
307 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 357 sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);
308 358
309 sb[4].StatID = (uint) Stats.Agents; 359 sb[4].StatID = (uint) Stats.Agents;
310 sb[4].StatValue = m_rootAgents; 360 sb[4].StatValue = m_rootAgents;
@@ -319,38 +369,31 @@ namespace OpenSim.Region.Framework.Scenes
319 sb[7].StatValue = m_activePrim; 369 sb[7].StatValue = m_activePrim;
320 370
321 sb[8].StatID = (uint)Stats.FrameMS; 371 sb[8].StatID = (uint)Stats.FrameMS;
322 // sb[8].StatValue = m_frameMS / statsUpdateFactor; 372 sb[8].StatValue = m_frameMS / framesUpdated;
323 sb[8].StatValue = TotalFrameTime;
324 373
325 sb[9].StatID = (uint)Stats.NetMS; 374 sb[9].StatID = (uint)Stats.NetMS;
326 // sb[9].StatValue = m_netMS / statsUpdateFactor; 375 sb[9].StatValue = m_netMS / framesUpdated;
327 sb[9].StatValue = m_netMS * perframe;
328 376
329 sb[10].StatID = (uint)Stats.PhysicsMS; 377 sb[10].StatID = (uint)Stats.PhysicsMS;
330 // sb[10].StatValue = m_physicsMS / statsUpdateFactor; 378 sb[10].StatValue = m_physicsMS / framesUpdated;
331 sb[10].StatValue = m_physicsMS * perframe;
332 379
333 sb[11].StatID = (uint)Stats.ImageMS ; 380 sb[11].StatID = (uint)Stats.ImageMS ;
334 // sb[11].StatValue = m_imageMS / statsUpdateFactor; 381 sb[11].StatValue = m_imageMS / framesUpdated;
335 sb[11].StatValue = m_imageMS * perframe;
336 382
337 sb[12].StatID = (uint)Stats.OtherMS; 383 sb[12].StatID = (uint)Stats.OtherMS;
338 // sb[12].StatValue = m_otherMS / statsUpdateFactor; 384 sb[12].StatValue = m_otherMS / framesUpdated;
339 sb[12].StatValue = m_otherMS * perframe;
340
341 385
342 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 386 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
343 sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor); 387 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
344 388
345 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 389 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
346 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 390 sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);
347 391
348 sb[15].StatID = (uint)Stats.UnAckedBytes; 392 sb[15].StatID = (uint)Stats.UnAckedBytes;
349 sb[15].StatValue = m_unAckedBytes; 393 sb[15].StatValue = m_unAckedBytes;
350 394
351 sb[16].StatID = (uint)Stats.AgentMS; 395 sb[16].StatID = (uint)Stats.AgentMS;
352// sb[16].StatValue = m_agentMS / statsUpdateFactor; 396 sb[16].StatValue = m_agentMS / framesUpdated;
353 sb[16].StatValue = m_agentMS * perframe;
354 397
355 sb[17].StatID = (uint)Stats.PendingDownloads; 398 sb[17].StatID = (uint)Stats.PendingDownloads;
356 sb[17].StatValue = m_pendingDownloads; 399 sb[17].StatValue = m_pendingDownloads;
@@ -362,15 +405,12 @@ namespace OpenSim.Region.Framework.Scenes
362 sb[19].StatValue = m_activeScripts; 405 sb[19].StatValue = m_activeScripts;
363 406
364 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 407 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
365 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 408 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
366 409
367 sb[21].StatID = (uint)Stats.SimSpareTime; 410 sb[21].StatID = (uint)Stats.SimSpareMs;
368 sb[21].StatValue = sparetime; 411 sb[21].StatValue = m_spareMS / framesUpdated;
369 412
370 sb[22].StatID = (uint)Stats.SimSleepTime; 413 for (int i = 0; i < 22; i++)
371 sb[22].StatValue = sleeptime;
372
373 for (int i = 0; i < 23; i++)
374 { 414 {
375 lastReportedSimStats[i] = sb[i].StatValue; 415 lastReportedSimStats[i] = sb[i].StatValue;
376 } 416 }
@@ -387,13 +427,32 @@ namespace OpenSim.Region.Framework.Scenes
387 } 427 }
388 428
389 // Extra statistics that aren't currently sent to clients 429 // Extra statistics that aren't currently sent to clients
390 LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor; 430 lock (m_lastReportedExtraSimStats)
431 {
432 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
433
434 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
435
436 if (physicsStats != null)
437 {
438 foreach (KeyValuePair<string, float> tuple in physicsStats)
439 {
440 // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
441 // Need to change things so that stats source can indicate whether they are per second or
442 // per frame.
443 if (tuple.Key.EndsWith("MS"))
444 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
445 else
446 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
447 }
448 }
449 }
391 450
392 resetvalues(); 451 ResetValues();
393 } 452 }
394 } 453 }
395 454
396 private void resetvalues() 455 private void ResetValues()
397 { 456 {
398 m_timeDilation = 0; 457 m_timeDilation = 0;
399 m_fps = 0; 458 m_fps = 0;
@@ -411,7 +470,7 @@ namespace OpenSim.Region.Framework.Scenes
411 m_physicsMS = 0; 470 m_physicsMS = 0;
412 m_imageMS = 0; 471 m_imageMS = 0;
413 m_otherMS = 0; 472 m_otherMS = 0;
414 m_sleeptimeMS = 0; 473 m_spareMS = 0;
415 474
416//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. 475//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
417//Ckrinke m_scriptMS = 0; 476//Ckrinke m_scriptMS = 0;
@@ -433,13 +492,6 @@ namespace OpenSim.Region.Framework.Scenes
433 m_timeDilation = td; 492 m_timeDilation = td;
434 } 493 }
435 494
436 public void SetRootAgents(int rootAgents)
437 {
438 m_rootAgents = rootAgents;
439 CheckStatSanity();
440
441 }
442
443 internal void CheckStatSanity() 495 internal void CheckStatSanity()
444 { 496 {
445 if (m_rootAgents < 0 || m_childAgents < 0) 497 if (m_rootAgents < 0 || m_childAgents < 0)
@@ -456,22 +508,6 @@ namespace OpenSim.Region.Framework.Scenes
456 } 508 }
457 } 509 }
458 510
459 public void SetChildAgents(int childAgents)
460 {
461 m_childAgents = childAgents;
462 CheckStatSanity();
463 }
464
465 public void SetObjects(int objects)
466 {
467 m_numPrim = objects;
468 }
469
470 public void SetActiveObjects(int objects)
471 {
472 m_activePrim = objects;
473 }
474
475 public void AddFPS(int frames) 511 public void AddFPS(int frames)
476 { 512 {
477 m_fps += frames; 513 m_fps += frames;
@@ -513,6 +549,11 @@ namespace OpenSim.Region.Framework.Scenes
513 m_frameMS += ms; 549 m_frameMS += ms;
514 } 550 }
515 551
552 public void AddSpareMS(int ms)
553 {
554 m_spareMS += ms;
555 }
556
516 public void addNetMS(int ms) 557 public void addNetMS(int ms)
517 { 558 {
518 m_netMS += ms; 559 m_netMS += ms;
@@ -538,15 +579,13 @@ namespace OpenSim.Region.Framework.Scenes
538 m_otherMS += ms; 579 m_otherMS += ms;
539 } 580 }
540 581
541 public void addSleepMS(int ms)
542 {
543 m_sleeptimeMS += ms;
544 }
545
546 public void AddPendingDownloads(int count) 582 public void AddPendingDownloads(int count)
547 { 583 {
548 m_pendingDownloads += count; 584 m_pendingDownloads += count;
549 if (m_pendingDownloads < 0) m_pendingDownloads = 0; 585
586 if (m_pendingDownloads < 0)
587 m_pendingDownloads = 0;
588
550 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads); 589 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads);
551 } 590 }
552 591
@@ -555,11 +594,6 @@ namespace OpenSim.Region.Framework.Scenes
555 m_scriptLinesPerSecond += count; 594 m_scriptLinesPerSecond += count;
556 } 595 }
557 596
558 public void SetActiveScripts(int count)
559 {
560 m_activeScripts = count;
561 }
562
563 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) 597 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes)
564 { 598 {
565 AddInPackets(inPackets); 599 AddInPackets(inPackets);
@@ -568,5 +602,11 @@ namespace OpenSim.Region.Framework.Scenes
568 } 602 }
569 603
570 #endregion 604 #endregion
605
606 public Dictionary<string, float> GetExtraSimStats()
607 {
608 lock (m_lastReportedExtraSimStats)
609 return new Dictionary<string, float>(m_lastReportedExtraSimStats);
610 }
571 } 611 }
572} 612}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
index ab6311b..4a21dc9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Text; 31using System.Text;
31using NUnit.Framework; 32using NUnit.Framework;
32using OpenMetaverse; 33using OpenMetaverse;
@@ -68,11 +69,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
68 Vector3 position = new Vector3(200,200,21); 69 Vector3 position = new Vector3(200,200,21);
69 70
70 foreach (Border b in testborders) 71 foreach (Border b in testborders)
71 {
72 Assert.That(!b.TestCross(position)); 72 Assert.That(!b.TestCross(position));
73 73
74 }
75
76 position = new Vector3(200,280,21); 74 position = new Vector3(200,280,21);
77 Assert.That(NorthBorder.TestCross(position)); 75 Assert.That(NorthBorder.TestCross(position));
78 76
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index a5d2b23..ea9fc93 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
45 { 45 {
46 static public Random random; 46 static public Random random;
47 SceneObjectGroup found; 47 SceneObjectGroup found;
48 Scene scene = SceneHelpers.SetupScene(); 48 Scene scene = new SceneHelpers().SetupScene();
49 49
50 [Test] 50 [Test]
51 public void T010_AddObjects() 51 public void T010_AddObjects()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 9a60e50..d23c965 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -26,7 +26,9 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Reflection; 30using System.Reflection;
31using System.Text;
30using NUnit.Framework; 32using NUnit.Framework;
31using OpenMetaverse; 33using OpenMetaverse;
32using OpenSim.Framework; 34using OpenSim.Framework;
@@ -44,7 +46,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
44 public void TestDuplicateObject() 46 public void TestDuplicateObject()
45 { 47 {
46 TestHelpers.InMethod(); 48 TestHelpers.InMethod();
47 Scene scene = SceneHelpers.SetupScene(); 49// TestHelpers.EnableLogging();
50
51 Scene scene = new SceneHelpers().SetupScene();
48 52
49 UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); 53 UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010");
50 string part1Name = "part1"; 54 string part1Name = "part1";
@@ -82,6 +86,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
82 Assert.That(dupePart1.PhysActor, Is.Not.Null); 86 Assert.That(dupePart1.PhysActor, Is.Not.Null);
83 Assert.That(dupePart2.PhysActor, Is.Not.Null); 87 Assert.That(dupePart2.PhysActor, Is.Not.Null);
84 */ 88 */
89
90// TestHelpers.DisableLogging();
85 } 91 }
86 } 92 }
87} \ No newline at end of file 93} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 7737d8e..453e077 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
88 { 88 {
89 TestHelpers.InMethod(); 89 TestHelpers.InMethod();
90 90
91 Scene scene = SceneHelpers.SetupScene(); 91 Scene scene = new SceneHelpers().SetupScene();
92 int partsToTestCount = 3; 92 int partsToTestCount = 3;
93 93
94 SceneObjectGroup so 94 SceneObjectGroup so
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
118 { 118 {
119 TestHelpers.InMethod(); 119 TestHelpers.InMethod();
120 120
121 Scene scene = SceneHelpers.SetupScene(); 121 Scene scene = new SceneHelpers().SetupScene();
122 122
123 string obj1Name = "Alfred"; 123 string obj1Name = "Alfred";
124 string obj2Name = "Betty"; 124 string obj2Name = "Betty";
@@ -152,7 +152,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
152 { 152 {
153 TestHelpers.InMethod(); 153 TestHelpers.InMethod();
154 154
155 Scene scene = SceneHelpers.SetupScene(); 155 Scene scene = new SceneHelpers().SetupScene();
156 int partsToTestCount = 3; 156 int partsToTestCount = 3;
157 157
158 SceneObjectGroup so 158 SceneObjectGroup so
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
185 { 185 {
186 TestHelpers.InMethod(); 186 TestHelpers.InMethod();
187 187
188 TestScene scene = SceneHelpers.SetupScene(); 188 TestScene scene = new SceneHelpers().SetupScene();
189 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 189 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
190 scene.DeleteSceneObject(part.ParentGroup, false); 190 scene.DeleteSceneObject(part.ParentGroup, false);
191 191
@@ -204,7 +204,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
204 204
205 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 205 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
206 206
207 TestScene scene = SceneHelpers.SetupScene(); 207 TestScene scene = new SceneHelpers().SetupScene();
208 208
209 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 209 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
210 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 210 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index 654b1a2..0076f41 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 61
62 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 62 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
63 63
64 TestScene scene = SceneHelpers.SetupScene(); 64 TestScene scene = new SceneHelpers().SetupScene();
65 IConfigSource configSource = new IniConfigSource(); 65 IConfigSource configSource = new IniConfigSource();
66 IConfig config = configSource.AddConfig("Startup"); 66 IConfig config = configSource.AddConfig("Startup");
67 config.Set("serverside_object_permissions", true); 67 config.Set("serverside_object_permissions", true);
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
100 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 100 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
101 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); 101 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
102 102
103 TestScene scene = SceneHelpers.SetupScene(); 103 TestScene scene = new SceneHelpers().SetupScene();
104 IConfigSource configSource = new IniConfigSource(); 104 IConfigSource configSource = new IniConfigSource();
105 IConfig config = configSource.AddConfig("Startup"); 105 IConfig config = configSource.AddConfig("Startup");
106 config.Set("serverside_object_permissions", true); 106 config.Set("serverside_object_permissions", true);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index be5b4a8..1add3dd 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
55 UUID ownerId = TestHelpers.ParseTail(0x1); 55 UUID ownerId = TestHelpers.ParseTail(0x1);
56 int nParts = 3; 56 int nParts = 3;
57 57
58 TestScene scene = SceneHelpers.SetupScene(); 58 TestScene scene = new SceneHelpers().SetupScene();
59 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10); 59 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10);
60 scene.AddSceneObject(sog1); 60 scene.AddSceneObject(sog1);
61 scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId }); 61 scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId });
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
71 71
72 bool debugtest = false; 72 bool debugtest = false;
73 73
74 Scene scene = SceneHelpers.SetupScene(); 74 Scene scene = new SceneHelpers().SetupScene();
75 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); 75 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene);
76 SceneObjectGroup grp1 = part1.ParentGroup; 76 SceneObjectGroup grp1 = part1.ParentGroup;
77 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 77 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene);
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
153 153
154 bool debugtest = false; 154 bool debugtest = false;
155 155
156 Scene scene = SceneHelpers.SetupScene(); 156 Scene scene = new SceneHelpers().SetupScene();
157 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); 157 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene);
158 SceneObjectGroup grp1 = part1.ParentGroup; 158 SceneObjectGroup grp1 = part1.ParentGroup;
159 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 159 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene);
@@ -286,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
286 TestHelpers.InMethod(); 286 TestHelpers.InMethod();
287 //log4net.Config.XmlConfigurator.Configure(); 287 //log4net.Config.XmlConfigurator.Configure();
288 288
289 TestScene scene = SceneHelpers.SetupScene(); 289 TestScene scene = new SceneHelpers().SetupScene();
290 290
291 string rootPartName = "rootpart"; 291 string rootPartName = "rootpart";
292 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); 292 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
@@ -325,7 +325,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
325 TestHelpers.InMethod(); 325 TestHelpers.InMethod();
326 //log4net.Config.XmlConfigurator.Configure(); 326 //log4net.Config.XmlConfigurator.Configure();
327 327
328 TestScene scene = SceneHelpers.SetupScene(); 328 TestScene scene = new SceneHelpers().SetupScene();
329 329
330 string rootPartName = "rootpart"; 330 string rootPartName = "rootpart";
331 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); 331 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index b49c6e7..0a94c19 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52 TestHelpers.InMethod(); 52 TestHelpers.InMethod();
53// log4net.Config.XmlConfigurator.Configure(); 53// log4net.Config.XmlConfigurator.Configure();
54 54
55 Scene scene = SceneHelpers.SetupScene(); 55 Scene scene = new SceneHelpers().SetupScene();
56 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; 56 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup;
57 57
58 g1.GroupResize(new Vector3(2, 3, 4)); 58 g1.GroupResize(new Vector3(2, 3, 4));
@@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
75 TestHelpers.InMethod(); 75 TestHelpers.InMethod();
76 //log4net.Config.XmlConfigurator.Configure(); 76 //log4net.Config.XmlConfigurator.Configure();
77 77
78 Scene scene = SceneHelpers.SetupScene(); 78 Scene scene = new SceneHelpers().SetupScene();
79 79
80 SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero); 80 SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero);
81 g1.RootPart.Scale = new Vector3(2, 3, 4); 81 g1.RootPart.Scale = new Vector3(2, 3, 4);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
index c582cf6..d2361f8 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52// UUID itemId = TestHelpers.ParseTail(0x2); 52// UUID itemId = TestHelpers.ParseTail(0x2);
53 string itemName = "Test Script Item"; 53 string itemName = "Test Script Item";
54 54
55 Scene scene = SceneHelpers.SetupScene(); 55 Scene scene = new SceneHelpers().SetupScene();
56 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); 56 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
57 scene.AddNewSceneObject(so, true); 57 scene.AddNewSceneObject(so, true);
58 58
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
new file mode 100644
index 0000000..6d255aa
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
@@ -0,0 +1,154 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Threading;
31using NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38
39namespace OpenSim.Region.Framework.Scenes.Tests
40{
41 /// <summary>
42 /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.)
43 /// </summary>
44 [TestFixture]
45 public class SceneObjectSpatialTests
46 {
47 TestScene m_scene;
48 UUID m_ownerId = TestHelpers.ParseTail(0x1);
49
50 [SetUp]
51 public void SetUp()
52 {
53 m_scene = new SceneHelpers().SetupScene();
54 }
55
56 [Test]
57 public void TestGetSceneObjectGroupPosition()
58 {
59 TestHelpers.InMethod();
60
61 Vector3 position = new Vector3(10, 20, 30);
62
63 SceneObjectGroup so
64 = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10);
65 so.AbsolutePosition = position;
66 m_scene.AddNewSceneObject(so, false);
67
68 Assert.That(so.AbsolutePosition, Is.EqualTo(position));
69 }
70
71 [Test]
72 public void TestGetRootPartPosition()
73 {
74 TestHelpers.InMethod();
75
76 Vector3 partPosition = new Vector3(10, 20, 30);
77
78 SceneObjectGroup so
79 = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10);
80 so.AbsolutePosition = partPosition;
81 m_scene.AddNewSceneObject(so, false);
82
83 Assert.That(so.RootPart.AbsolutePosition, Is.EqualTo(partPosition));
84 Assert.That(so.RootPart.GroupPosition, Is.EqualTo(partPosition));
85 Assert.That(so.RootPart.GetWorldPosition(), Is.EqualTo(partPosition));
86 Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition));
87 Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero));
88 }
89
90 [Test]
91 public void TestGetChildPartPosition()
92 {
93 TestHelpers.InMethod();
94
95 Vector3 rootPartPosition = new Vector3(10, 20, 30);
96 Vector3 childOffsetPosition = new Vector3(2, 3, 4);
97
98 SceneObjectGroup so
99 = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10);
100 so.AbsolutePosition = rootPartPosition;
101 so.Parts[1].OffsetPosition = childOffsetPosition;
102
103 m_scene.AddNewSceneObject(so, false);
104
105 // Calculate child absolute position.
106 Vector3 childPosition = new Vector3(rootPartPosition + childOffsetPosition);
107
108 SceneObjectPart childPart = so.Parts[1];
109 Assert.That(childPart.AbsolutePosition, Is.EqualTo(childPosition));
110 Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition));
111 Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition));
112 Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition));
113 Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition));
114 }
115
116 [Test]
117 public void TestGetChildPartPositionAfterObjectRotation()
118 {
119 TestHelpers.InMethod();
120
121 Vector3 rootPartPosition = new Vector3(10, 20, 30);
122 Vector3 childOffsetPosition = new Vector3(2, 3, 4);
123
124 SceneObjectGroup so
125 = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10);
126 so.AbsolutePosition = rootPartPosition;
127 so.Parts[1].OffsetPosition = childOffsetPosition;
128
129 m_scene.AddNewSceneObject(so, false);
130
131 so.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 0, -90 * Utils.DEG_TO_RAD));
132
133 // Calculate child absolute position.
134 Vector3 rotatedChildOffsetPosition
135 = new Vector3(childOffsetPosition.Y, -childOffsetPosition.X, childOffsetPosition.Z);
136
137 Vector3 childPosition = new Vector3(rootPartPosition + rotatedChildOffsetPosition);
138
139 SceneObjectPart childPart = so.Parts[1];
140
141 // FIXME: Should be childPosition after rotation?
142 Assert.That(childPart.AbsolutePosition, Is.EqualTo(rootPartPosition + childOffsetPosition));
143
144 Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition));
145 Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition));
146
147 // Relative to root part as (0, 0, 0)
148 Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition));
149
150 // Relative to root part as (0, 0, 0)
151 Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition));
152 }
153 }
154} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
index 2a342d5..742c769 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using NUnit.Framework; 31using NUnit.Framework;
31using OpenMetaverse; 32using OpenMetaverse;
@@ -43,24 +44,141 @@ namespace OpenSim.Region.Framework.Scenes.Tests
43 [TestFixture] 44 [TestFixture]
44 public class SceneObjectStatusTests 45 public class SceneObjectStatusTests
45 { 46 {
47 private TestScene m_scene;
48 private UUID m_ownerId = TestHelpers.ParseTail(0x1);
49 private SceneObjectGroup m_so1;
50 private SceneObjectGroup m_so2;
51
52 [SetUp]
53 public void Init()
54 {
55 m_scene = new SceneHelpers().SetupScene();
56 m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
57 m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
58 }
59
46 [Test] 60 [Test]
47 public void TestSetPhantom() 61 public void TestSetPhantomSinglePrim()
48 { 62 {
49 TestHelpers.InMethod(); 63 TestHelpers.InMethod();
50 64
51// Scene scene = SceneSetupHelpers.SetupScene(); 65 m_scene.AddSceneObject(m_so1);
52 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); 66
53 SceneObjectPart rootPart = so.RootPart; 67 SceneObjectPart rootPart = m_so1.RootPart;
54 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 68 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
55 69
56 so.ScriptSetPhantomStatus(true); 70 m_so1.ScriptSetPhantomStatus(true);
57 71
58// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); 72// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
59 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); 73 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
60 74
61 so.ScriptSetPhantomStatus(false); 75 m_so1.ScriptSetPhantomStatus(false);
62 76
63 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 77 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
64 } 78 }
79
80 [Test]
81 public void TestSetPhysicsSinglePrim()
82 {
83 TestHelpers.InMethod();
84
85 m_scene.AddSceneObject(m_so1);
86
87 SceneObjectPart rootPart = m_so1.RootPart;
88 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
89
90 m_so1.ScriptSetPhysicsStatus(true);
91
92// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
93 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
94
95 m_so1.ScriptSetPhysicsStatus(false);
96
97 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
98 }
99
100 [Test]
101 public void TestSetPhysicsLinkset()
102 {
103 TestHelpers.InMethod();
104
105 m_scene.AddSceneObject(m_so1);
106 m_scene.AddSceneObject(m_so2);
107
108 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
109
110 m_so1.ScriptSetPhysicsStatus(true);
111
112 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
113 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
114
115 m_so1.ScriptSetPhysicsStatus(false);
116
117 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
118 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
119
120 m_so1.ScriptSetPhysicsStatus(true);
121
122 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
123 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
124 }
125
126 /// <summary>
127 /// Test that linking results in the correct physical status for all linkees.
128 /// </summary>
129 [Test]
130 public void TestLinkPhysicsBothPhysical()
131 {
132 TestHelpers.InMethod();
133
134 m_scene.AddSceneObject(m_so1);
135 m_scene.AddSceneObject(m_so2);
136
137 m_so1.ScriptSetPhysicsStatus(true);
138 m_so2.ScriptSetPhysicsStatus(true);
139
140 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
141
142 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
143 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
144 }
145
146 /// <summary>
147 /// Test that linking results in the correct physical status for all linkees.
148 /// </summary>
149 [Test]
150 public void TestLinkPhysicsRootPhysicalOnly()
151 {
152 TestHelpers.InMethod();
153
154 m_scene.AddSceneObject(m_so1);
155 m_scene.AddSceneObject(m_so2);
156
157 m_so1.ScriptSetPhysicsStatus(true);
158
159 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
160
161 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
162 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
163 }
164
165 /// <summary>
166 /// Test that linking results in the correct physical status for all linkees.
167 /// </summary>
168 [Test]
169 public void TestLinkPhysicsChildPhysicalOnly()
170 {
171 TestHelpers.InMethod();
172
173 m_scene.AddSceneObject(m_so1);
174 m_scene.AddSceneObject(m_so2);
175
176 m_so2.ScriptSetPhysicsStatus(true);
177
178 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
179
180 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
181 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
182 }
65 } 183 }
66} \ No newline at end of file 184} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
index c13d82e..c7eaff9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 58
59 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 59 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
60 60
61 TestScene scene = SceneHelpers.SetupScene(); 61 TestScene scene = new SceneHelpers().SetupScene();
62 IConfigSource configSource = new IniConfigSource(); 62 IConfigSource configSource = new IniConfigSource();
63 63
64 IConfig startupConfig = configSource.AddConfig("Startup"); 64 IConfig startupConfig = configSource.AddConfig("Startup");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index ed9b179..02c45ef 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -67,10 +67,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
67 public void Init() 67 public void Init()
68 { 68 {
69 TestHelpers.InMethod(); 69 TestHelpers.InMethod();
70 70
71 scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); 71 SceneHelpers sh = new SceneHelpers();
72 scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); 72
73 scene3 = SceneHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); 73 scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
74 scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
75 scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
74 76
75 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 77 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
76 interregionComms.Initialise(new IniConfigSource()); 78 interregionComms.Initialise(new IniConfigSource());
@@ -99,9 +101,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
99 public void TestCloseAgent() 101 public void TestCloseAgent()
100 { 102 {
101 TestHelpers.InMethod(); 103 TestHelpers.InMethod();
102// log4net.Config.XmlConfigurator.Configure(); 104// TestHelpers.EnableLogging();
103 105
104 TestScene scene = SceneHelpers.SetupScene(); 106 TestScene scene = new SceneHelpers().SetupScene();
105 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 107 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
106 108
107 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); 109 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null);
@@ -112,6 +114,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
112 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); 114 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
113 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); 115 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
114 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0)); 116 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0));
117
118// TestHelpers.DisableLogging();
115 } 119 }
116 120
117 [Test] 121 [Test]
@@ -126,7 +130,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
126 IConfig config = configSource.AddConfig("Modules"); 130 IConfig config = configSource.AddConfig("Modules");
127 config.Set("SimulationServices", "LocalSimulationConnectorModule"); 131 config.Set("SimulationServices", "LocalSimulationConnectorModule");
128 132
129 TestScene scene = SceneHelpers.SetupScene(); 133 SceneHelpers sceneHelpers = new SceneHelpers();
134 TestScene scene = sceneHelpers.SetupScene();
130 SceneHelpers.SetupSceneModules(scene, configSource, lsc); 135 SceneHelpers.SetupSceneModules(scene, configSource, lsc);
131 136
132 UUID agentId = TestHelpers.ParseTail(0x01); 137 UUID agentId = TestHelpers.ParseTail(0x01);
@@ -176,8 +181,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
176 181
177// UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); 182// UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
178 183
179 TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); 184 TestScene myScene1 = new SceneHelpers().SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
180 TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); 185 TestScene myScene2 = new SceneHelpers().SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
181 186
182 IConfigSource configSource = new IniConfigSource(); 187 IConfigSource configSource = new IniConfigSource();
183 IConfig config = configSource.AddConfig("Startup"); 188 IConfig config = configSource.AddConfig("Startup");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
index 89f8007..646e5fa 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
59 TestHelpers.InMethod(); 59 TestHelpers.InMethod();
60// log4net.Config.XmlConfigurator.Configure(); 60// log4net.Config.XmlConfigurator.Configure();
61 61
62 TestScene scene = SceneHelpers.SetupScene(); 62 TestScene scene = new SceneHelpers().SetupScene();
63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
64 sp.Flying = true; 64 sp.Flying = true;
65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); 65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate());
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index cfea10d..1d1ff88 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
64 [SetUp] 64 [SetUp]
65 public void Init() 65 public void Init()
66 { 66 {
67 m_scene = SceneHelpers.SetupScene(); 67 m_scene = new SceneHelpers().SetupScene();
68 } 68 }
69 69
70 [Test] 70 [Test]
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
index b7b8db4..313e350 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
50 [SetUp] 50 [SetUp]
51 public void Init() 51 public void Init()
52 { 52 {
53 m_scene = SceneHelpers.SetupScene(); 53 m_scene = new SceneHelpers().SetupScene();
54 m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); 54 m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
55 } 55 }
56 56
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index bebc10c..a407f01 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -34,10 +34,14 @@ using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.Framework;
38using OpenSim.Region.CoreModules.Framework.EntityTransfer;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 39using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
40using OpenSim.Region.CoreModules.World.Permissions;
38using OpenSim.Tests.Common; 41using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 42using OpenSim.Tests.Common.Mock;
40using System.Threading; 43using System.IO;
44using System.Text;
41 45
42namespace OpenSim.Region.Framework.Scenes.Tests 46namespace OpenSim.Region.Framework.Scenes.Tests
43{ 47{
@@ -47,145 +51,367 @@ namespace OpenSim.Region.Framework.Scenes.Tests
47 [TestFixture] 51 [TestFixture]
48 public class ScenePresenceTeleportTests 52 public class ScenePresenceTeleportTests
49 { 53 {
50 /// <summary> 54 [TestFixtureSetUp]
51 /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. 55 public void FixtureInit()
52 /// </summary> 56 {
53 /// Does not yet do what is says on the tin. 57 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
54 /// Commenting for now 58 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
55 //[Test, LongRunning] 59 }
56 public void TestSimpleNotNeighboursTeleport() 60
61 [TestFixtureTearDown]
62 public void TearDown()
63 {
64 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
65 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
66 // tests really shouldn't).
67 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
68 }
69
70 [Test]
71 public void TestSameRegionTeleport()
57 { 72 {
58 TestHelpers.InMethod(); 73 TestHelpers.InMethod();
59 ThreadRunResults results = new ThreadRunResults(); 74// log4net.Config.XmlConfigurator.Configure();
60 results.Result = false; 75
61 results.Message = "Test did not run"; 76 EntityTransferModule etm = new EntityTransferModule();
62 TestRunning testClass = new TestRunning(results); 77
78 IConfigSource config = new IniConfigSource();
79 config.AddConfig("Modules");
80 // Not strictly necessary since FriendsModule assumes it is the default (!)
81 config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
82
83 TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
84 SceneHelpers.SetupSceneModules(scene, config, etm);
85
86 Vector3 teleportPosition = new Vector3(10, 11, 12);
87 Vector3 teleportLookAt = new Vector3(20, 21, 22);
88
89 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
90 sp.AbsolutePosition = new Vector3(30, 31, 32);
91 scene.RequestTeleportLocation(
92 sp.ControllingClient,
93 scene.RegionInfo.RegionHandle,
94 teleportPosition,
95 teleportLookAt,
96 (uint)TeleportFlags.ViaLocation);
63 97
64 Thread testThread = new Thread(testClass.run); 98 Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));
65 99
66 // Seems kind of redundant to start a thread and then join it, however.. We need to protect against 100 Assert.That(scene.GetRootAgentCount(), Is.EqualTo(1));
67 // A thread abort exception in the simulator code. 101 Assert.That(scene.GetChildAgentCount(), Is.EqualTo(0));
68 testThread.Start();
69 testThread.Join();
70 102
71 Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message); 103 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
72 // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 104 // position instead).
105// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
73 } 106 }
74 107
75 [TearDown] 108 [Test]
76 public void TearDown() 109 public void TestSameSimulatorSeparatedRegionsTeleport()
77 { 110 {
78 try 111 TestHelpers.InMethod();
79 { 112// log4net.Config.XmlConfigurator.Configure();
80 if (MainServer.Instance != null) MainServer.Instance.Stop(); 113
81 } 114 UUID userId = TestHelpers.ParseTail(0x1);
82 catch (NullReferenceException) 115
83 { } 116 EntityTransferModule etmA = new EntityTransferModule();
117 EntityTransferModule etmB = new EntityTransferModule();
118 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
119
120 IConfigSource config = new IniConfigSource();
121 IConfig modulesConfig = config.AddConfig("Modules");
122 modulesConfig.Set("EntityTransferModule", etmA.Name);
123 modulesConfig.Set("SimulationServices", lscm.Name);
124 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
125
126 // In order to run a single threaded regression test we do not want the entity transfer module waiting
127 // for a callback from the destination scene before removing its avatar data.
128 entityTransferConfig.Set("wait_for_callback", false);
129
130 SceneHelpers sh = new SceneHelpers();
131 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
132 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
133
134 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
135 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
136 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
137
138 Vector3 teleportPosition = new Vector3(10, 11, 12);
139 Vector3 teleportLookAt = new Vector3(20, 21, 22);
140
141 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
142 sp.AbsolutePosition = new Vector3(30, 31, 32);
143
144 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
145 // UDP stack (?)
146// ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB;
147
148 sceneA.RequestTeleportLocation(
149 sp.ControllingClient,
150 sceneB.RegionInfo.RegionHandle,
151 teleportPosition,
152 teleportLookAt,
153 (uint)TeleportFlags.ViaLocation);
154
155 ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
156
157 Assert.That(sceneA.GetScenePresence(userId), Is.Null);
158
159 ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
160 Assert.That(sceneBSp, Is.Not.Null);
161 Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
162 Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
163
164 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
165 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
166 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
167 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
168
169 // TODO: Add assertions to check correct circuit details in both scenes.
170
171 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
172 // position instead).
173// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
84 } 174 }
85 175
86 } 176 /// <summary>
177 /// Test teleport procedures when the target simulator returns false when queried about access.
178 /// </summary>
179 [Test]
180 public void TestSameSimulatorSeparatedRegionsQueryAccessFails()
181 {
182 TestHelpers.InMethod();
183// TestHelpers.EnableLogging();
87 184
88 public class ThreadRunResults 185 UUID userId = TestHelpers.ParseTail(0x1);
89 { 186 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
90 public bool Result = false;
91 public string Message = string.Empty;
92 }
93 187
94 public class TestRunning 188 EntityTransferModule etmA = new EntityTransferModule();
95 { 189 EntityTransferModule etmB = new EntityTransferModule();
96 public ThreadRunResults results; 190
97 public TestRunning(ThreadRunResults t) 191 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
192
193 IConfigSource config = new IniConfigSource();
194 config.AddConfig("Modules");
195 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
196 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
197
198 config.AddConfig("EntityTransfer");
199
200 // In order to run a single threaded regression test we do not want the entity transfer module waiting
201 // for a callback from the destination scene before removing its avatar data.
202 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
203
204 config.AddConfig("Startup");
205 config.Configs["Startup"].Set("serverside_object_permissions", true);
206
207 SceneHelpers sh = new SceneHelpers();
208 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
209 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
210
211 SceneHelpers.SetupSceneModules(sceneA, config, etmA );
212
213 // We need to set up the permisions module on scene B so that our later use of agent limit to deny
214 // QueryAccess won't succeed anyway because administrators are always allowed in and the default
215 // IsAdministrator if no permissions module is present is true.
216 SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
217
218 // Shared scene modules
219 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
220
221 Vector3 teleportPosition = new Vector3(10, 11, 12);
222 Vector3 teleportLookAt = new Vector3(20, 21, 22);
223
224 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
225 sp.AbsolutePosition = preTeleportPosition;
226
227 // Make sceneB return false on query access
228 sceneB.RegionInfo.RegionSettings.AgentLimit = 0;
229
230 sceneA.RequestTeleportLocation(
231 sp.ControllingClient,
232 sceneB.RegionInfo.RegionHandle,
233 teleportPosition,
234 teleportLookAt,
235 (uint)TeleportFlags.ViaLocation);
236
237// ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
238
239 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
240
241 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
242 Assert.That(sceneASp, Is.Not.Null);
243 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
244 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
245
246 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
247 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
248 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
249 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
250
251 // TODO: Add assertions to check correct circuit details in both scenes.
252
253 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
254 // position instead).
255// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
256
257// TestHelpers.DisableLogging();
258 }
259
260 /// <summary>
261 /// Test teleport procedures when the target simulator create agent step is refused.
262 /// </summary>
263 [Test]
264 public void TestSameSimulatorSeparatedRegionsCreateAgentFails()
98 { 265 {
99 results = t; 266 TestHelpers.InMethod();
267// TestHelpers.EnableLogging();
268
269 UUID userId = TestHelpers.ParseTail(0x1);
270 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
271
272 EntityTransferModule etmA = new EntityTransferModule();
273 EntityTransferModule etmB = new EntityTransferModule();
274 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
275
276 IConfigSource config = new IniConfigSource();
277 config.AddConfig("Modules");
278 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
279 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
280
281 config.AddConfig("EntityTransfer");
282
283 // In order to run a single threaded regression test we do not want the entity transfer module waiting
284 // for a callback from the destination scene before removing its avatar data.
285 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
286
287 SceneHelpers sh = new SceneHelpers();
288 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
289 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
290
291 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
292 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
293
294 // Shared scene modules
295 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
296
297 Vector3 teleportPosition = new Vector3(10, 11, 12);
298 Vector3 teleportLookAt = new Vector3(20, 21, 22);
299
300 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
301 sp.AbsolutePosition = preTeleportPosition;
302
303 // Make sceneB refuse CreateAgent
304 sceneB.LoginsDisabled = true;
305
306 sceneA.RequestTeleportLocation(
307 sp.ControllingClient,
308 sceneB.RegionInfo.RegionHandle,
309 teleportPosition,
310 teleportLookAt,
311 (uint)TeleportFlags.ViaLocation);
312
313// ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
314
315 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
316
317 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
318 Assert.That(sceneASp, Is.Not.Null);
319 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
320 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
321
322 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
323 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
324 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
325 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
326
327 // TODO: Add assertions to check correct circuit details in both scenes.
328
329 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
330 // position instead).
331// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
332
333// TestHelpers.DisableLogging();
100 } 334 }
101 public void run(object o) 335
336 [Test]
337 public void TestSameSimulatorNeighbouringRegionsTeleport()
102 { 338 {
103 339 TestHelpers.InMethod();
104 //results.Result = true; 340// TestHelpers.EnableLogging();
105 log4net.Config.XmlConfigurator.Configure(); 341
106 342 UUID userId = TestHelpers.ParseTail(0x1);
107 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 343
108 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 344 EntityTransferModule etmA = new EntityTransferModule();
109 345 EntityTransferModule etmB = new EntityTransferModule();
110 // shared module 346 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
111 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 347
112 348 IConfigSource config = new IniConfigSource();
113 349 IConfig modulesConfig = config.AddConfig("Modules");
114 Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010); 350 modulesConfig.Set("EntityTransferModule", etmA.Name);
115 SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 351 modulesConfig.Set("SimulationServices", lscm.Name);
116 sceneB.RegisterRegionWithGrid(); 352 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
117 353
118 Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000); 354 // In order to run a single threaded regression test we do not want the entity transfer module waiting
119 SceneHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); 355 // for a callback from the destination scene before removing its avatar data.
120 sceneA.RegisterRegionWithGrid(); 356 entityTransferConfig.Set("wait_for_callback", false);
121 357
122 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); 358 SceneHelpers sh = new SceneHelpers();
123 TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient; 359 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
124 360 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
125 ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>(); 361
126 362 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
127 results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl); 363 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
128 364 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
129 if (!results.Result) 365
130 { 366 Vector3 teleportPosition = new Vector3(10, 11, 12);
131 results.Message = "Incorrect caps object path set up in sceneA"; 367 Vector3 teleportLookAt = new Vector3(20, 21, 22);
132 return; 368
133 } 369 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
134 370 originalSp.AbsolutePosition = new Vector3(30, 31, 32);
135 /* 371
136 Assert.That( 372 ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId);
137 sceneACapsModule.GetCapsPath(agentId), 373 Assert.That(beforeSceneASp, Is.Not.Null);
138 Is.EqualTo(client.CapsSeedUrl), 374 Assert.That(beforeSceneASp.IsChildAgent, Is.False);
139 "Incorrect caps object path set up in sceneA"); 375
140 */ 376 ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
141 // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used. 377 Assert.That(beforeSceneBSp, Is.Not.Null);
142 378 Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
143 379
144 client.TeleportTargetScene = sceneB; 380 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
145 client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40)); 381 // UDP stack (?)
146 382// ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB;
147 results.Result = (sceneB.GetScenePresence(agentId) != null); 383
148 if (!results.Result) 384 sceneA.RequestTeleportLocation(
149 { 385 beforeSceneASp.ControllingClient,
150 results.Message = "Client does not have an agent in sceneB"; 386 sceneB.RegionInfo.RegionHandle,
151 return; 387 teleportPosition,
152 } 388 teleportLookAt,
153 389 (uint)TeleportFlags.ViaLocation);
154 //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); 390
155 391 ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide();
156 //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); 392
157 393 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
158 results.Result = (sceneA.GetScenePresence(agentId) == null); 394 Assert.That(afterSceneASp, Is.Not.Null);
159 if (!results.Result) 395 Assert.That(afterSceneASp.IsChildAgent, Is.True);
160 { 396
161 results.Message = "Client still had an agent in sceneA"; 397 ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
162 return; 398 Assert.That(afterSceneBSp, Is.Not.Null);
163 } 399 Assert.That(afterSceneBSp.IsChildAgent, Is.False);
164 400 Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
165 ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>(); 401 Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
166 402
167 403 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
168 results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + 404 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
169 "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl); 405 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
170 if (!results.Result) 406 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
171 { 407
172 results.Message = "Incorrect caps object path set up in sceneB"; 408 // TODO: Add assertions to check correct circuit details in both scenes.
173 return; 409
174 } 410 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
175 411 // position instead).
176 // Temporary assertion - caps url construction should at least be doable through a method. 412// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
177 /* 413
178 Assert.That( 414// TestHelpers.DisableLogging();
179 "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/",
180 Is.EqualTo(client.CapsSeedUrl),
181 "Incorrect caps object path set up in sceneB");
182 */
183 // This assertion will currently fail since we don't remove the caps paths when no longer needed
184 //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path");
185
186 // TODO: Check that more of everything is as it should be
187
188 // TODO: test what happens if we try to teleport to a region that doesn't exist
189 } 415 }
190 } 416 }
191} 417} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 5c9a77d..d722a09 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
60 { 60 {
61 TestHelpers.InMethod(); 61 TestHelpers.InMethod();
62 62
63 Scene scene = SceneHelpers.SetupScene(); 63 Scene scene = new SceneHelpers().SetupScene();
64 scene.Update(1); 64 scene.Update(1);
65 65
66 Assert.That(scene.Frame, Is.EqualTo(1)); 66 Assert.That(scene.Frame, Is.EqualTo(1));
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index 55c80f5..d15141b 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests
58 TestHelpers.InMethod(); 58 TestHelpers.InMethod();
59// log4net.Config.XmlConfigurator.Configure(); 59// log4net.Config.XmlConfigurator.Configure();
60 60
61 Scene scene = SceneHelpers.SetupScene(); 61 Scene scene = new SceneHelpers().SetupScene();
62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
63 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 63 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
64 SceneObjectPart sop1 = sog1.RootPart; 64 SceneObjectPart sop1 = sog1.RootPart;
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Framework.Tests
81 TestHelpers.InMethod(); 81 TestHelpers.InMethod();
82// log4net.Config.XmlConfigurator.Configure(); 82// log4net.Config.XmlConfigurator.Configure();
83 83
84 Scene scene = SceneHelpers.SetupScene(); 84 Scene scene = new SceneHelpers().SetupScene();
85 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 85 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
86 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 86 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
87 SceneObjectPart sop1 = sog1.RootPart; 87 SceneObjectPart sop1 = sog1.RootPart;
@@ -124,7 +124,7 @@ namespace OpenSim.Region.Framework.Tests
124 TestHelpers.InMethod(); 124 TestHelpers.InMethod();
125// log4net.Config.XmlConfigurator.Configure(); 125// log4net.Config.XmlConfigurator.Configure();
126 126
127 Scene scene = SceneHelpers.SetupScene(); 127 Scene scene = new SceneHelpers().SetupScene();
128 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 128 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
129 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 129 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
130 SceneObjectPart sop1 = sog1.RootPart; 130 SceneObjectPart sop1 = sog1.RootPart;
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Tests
153 TestHelpers.InMethod(); 153 TestHelpers.InMethod();
154// log4net.Config.XmlConfigurator.Configure(); 154// log4net.Config.XmlConfigurator.Configure();
155 155
156 Scene scene = SceneHelpers.SetupScene(); 156 Scene scene = new SceneHelpers().SetupScene();
157 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 157 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
158 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 158 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
159 SceneObjectPart sop1 = sog1.RootPart; 159 SceneObjectPart sop1 = sog1.RootPart;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
index 55fc1e7..44d2d45 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests
58 TestHelpers.InMethod(); 58 TestHelpers.InMethod();
59// log4net.Config.XmlConfigurator.Configure(); 59// log4net.Config.XmlConfigurator.Configure();
60 60
61 Scene scene = SceneHelpers.SetupScene(); 61 Scene scene = new SceneHelpers().SetupScene();
62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
63 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 63 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
64 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); 64 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Framework.Tests
85 TestHelpers.InMethod(); 85 TestHelpers.InMethod();
86// log4net.Config.XmlConfigurator.Configure(); 86// log4net.Config.XmlConfigurator.Configure();
87 87
88 Scene scene = SceneHelpers.SetupScene(); 88 Scene scene = new SceneHelpers().SetupScene();
89 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 89 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
90 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 90 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
91 InventoryFolderBase folder1 91 InventoryFolderBase folder1
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index d9fe87c..198e487 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
47 public void Init() 47 public void Init()
48 { 48 {
49 // FIXME: We don't need a full scene here - it would be enough to set up the asset service. 49 // FIXME: We don't need a full scene here - it would be enough to set up the asset service.
50 Scene scene = SceneHelpers.SetupScene(); 50 Scene scene = new SceneHelpers().SetupScene();
51 m_assetService = scene.AssetService; 51 m_assetService = scene.AssetService;
52 m_uuidGatherer = new UuidGatherer(m_assetService); 52 m_uuidGatherer = new UuidGatherer(m_assetService);
53 } 53 }