aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2010-03-30 21:34:27 +0100
committerMelanie2010-03-30 21:34:27 +0100
commit5693870fe26fae35a28f2d5103780434f4f40e57 (patch)
tree0e070fb6f11ab8763ac4f1f9a851a0061101d4d6 /OpenSim/Region
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
parentminor: commented out code removal (diff)
downloadopensim-SC_OLD-5693870fe26fae35a28f2d5103780434f4f40e57.zip
opensim-SC_OLD-5693870fe26fae35a28f2d5103780434f4f40e57.tar.gz
opensim-SC_OLD-5693870fe26fae35a28f2d5103780434f4f40e57.tar.bz2
opensim-SC_OLD-5693870fe26fae35a28f2d5103780434f4f40e57.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs50
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs31
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs39
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs34
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/WindModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs91
-rw-r--r--OpenSim/Region/Examples/SimpleModule/RegionModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsModule.cs39
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs204
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs186
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs58
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs41
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs34
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs12
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs4
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs38
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs93
-rw-r--r--OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs14
41 files changed, 622 insertions, 563 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 8cd47fb..0762ed0 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -40,7 +40,6 @@ using OpenMetaverse.Packets;
40using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Client; 42using OpenSim.Framework.Client;
43
44using OpenSim.Framework.Statistics; 43using OpenSim.Framework.Statistics;
45using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
@@ -353,6 +352,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
353 protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates; 352 protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates;
354 private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates; 353 private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates;
355 private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates; 354 private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates;
355
356 /// <value>
357 /// List used in construction of data blocks for an object update packet. This is to stop us having to
358 /// continually recreate it.
359 /// </value>
360 protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
361
362 /// <value>
363 /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
364 /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
365 /// ownerless phantom.
366 ///
367 /// All manipulation of this set has to occur under a m_primFullUpdate.SyncRoot lock
368 ///
369 /// </value>
370 protected HashSet<uint> m_killRecord;
371
356 private int m_moneyBalance; 372 private int m_moneyBalance;
357 private int m_animationSequenceNumber = 1; 373 private int m_animationSequenceNumber = 1;
358 private bool m_SendLogoutPacketWhenClosing = true; 374 private bool m_SendLogoutPacketWhenClosing = true;
@@ -449,6 +465,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
449 m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); 465 m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
450 m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); 466 m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
451 m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count); 467 m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count);
468 m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
469 m_killRecord = new HashSet<uint>();
452 470
453 m_assetService = m_scene.RequestModuleInterface<IAssetService>(); 471 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
454 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>(); 472 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>();
@@ -1474,7 +1492,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1474 kill.ObjectData[0].ID = localID; 1492 kill.ObjectData[0].ID = localID;
1475 kill.Header.Reliable = true; 1493 kill.Header.Reliable = true;
1476 kill.Header.Zerocoded = true; 1494 kill.Header.Zerocoded = true;
1477 OutPacket(kill, ThrottleOutPacketType.State); 1495
1496 lock (m_primFullUpdates.SyncRoot)
1497 {
1498 m_killRecord.Add(localID);
1499 OutPacket(kill, ThrottleOutPacketType.State);
1500 }
1478 } 1501 }
1479 1502
1480 /// <summary> 1503 /// <summary>
@@ -3521,21 +3544,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3521 if (count == 0) 3544 if (count == 0)
3522 return; 3545 return;
3523 3546
3524 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; 3547 m_fullUpdateDataBlocksBuilder.Clear();
3548
3525 for (int i = 0; i < count; i++) 3549 for (int i = 0; i < count; i++)
3526 { 3550 {
3527 outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); 3551 ObjectUpdatePacket.ObjectDataBlock block = m_primFullUpdates.Dequeue();
3528 3552
3553 if (!m_killRecord.Contains(block.ID))
3554 {
3555 m_fullUpdateDataBlocksBuilder.Add(block);
3556
3529// string text = Util.FieldToString(outPacket.ObjectData[i].Text); 3557// string text = Util.FieldToString(outPacket.ObjectData[i].Text);
3530// if (text.IndexOf("\n") >= 0) 3558// if (text.IndexOf("\n") >= 0)
3531// text = text.Remove(text.IndexOf("\n")); 3559// text = text.Remove(text.IndexOf("\n"));
3532// m_log.DebugFormat( 3560// m_log.DebugFormat(
3533// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}", 3561// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}",
3534// outPacket.ObjectData[i].ID, text, Name); 3562// outPacket.ObjectData[i].ID, text, Name);
3563 }
3564// else
3565// {
3566// m_log.WarnFormat(
3567// "[CLIENT]: Preventing full update for {0} after kill to {1}", block.ID, Name);
3568// }
3535 } 3569 }
3536 }
3537 3570
3538 OutPacket(outPacket, ThrottleOutPacketType.State); 3571 outPacket.ObjectData = m_fullUpdateDataBlocksBuilder.ToArray();
3572
3573 OutPacket(outPacket, ThrottleOutPacketType.State);
3574 }
3539 } 3575 }
3540 3576
3541 public void SendPrimTerseUpdate(SendPrimitiveTerseData data) 3577 public void SendPrimTerseUpdate(SendPrimitiveTerseData data)
@@ -5965,7 +6001,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5965 || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f) 6001 || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
5966 { 6002 {
5967 ScenePresence avatar = null; 6003 ScenePresence avatar = null;
5968 if (((Scene)m_scene).TryGetAvatar(AgentId, out avatar)) 6004 if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
5969 { 6005 {
5970 if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f) 6006 if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
5971 { 6007 {
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 0ec87e5..e683821 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -98,10 +98,10 @@ namespace OpenSim.Region.ClientStack
98 98
99 if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) 99 if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort))
100 { 100 {
101 m_log.Error("[HTTP]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); 101 m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports");
102 } 102 }
103 103
104 m_log.Info("[REGION]: Starting HTTP server"); 104 m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort);
105 m_httpServer.Start(); 105 m_httpServer.Start();
106 106
107 MainServer.Instance = m_httpServer; 107 MainServer.Instance = m_httpServer;
@@ -129,4 +129,4 @@ namespace OpenSim.Region.ClientStack
129 return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier); 129 return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier);
130 } 130 }
131 } 131 }
132} 132} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index f54e41a..23828ef 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
86 86
87 // Save avatar attachment information 87 // Save avatar attachment information
88 ScenePresence presence; 88 ScenePresence presence;
89 if (m_scene.AvatarFactory != null && m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) 89 if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
90 { 90 {
91 m_log.Info( 91 m_log.Info(
92 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 92 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
@@ -255,7 +255,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
255 AttachmentPt = att.RootPart.AttachmentPoint; 255 AttachmentPt = att.RootPart.AttachmentPoint;
256 256
257 ScenePresence presence; 257 ScenePresence presence;
258 if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) 258 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
259 { 259 {
260 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 260 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
261 item = m_scene.InventoryService.GetItem(item); 261 item = m_scene.InventoryService.GetItem(item);
@@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
299 } 299 }
300 300
301 ScenePresence presence; 301 ScenePresence presence;
302 if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) 302 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
303 { 303 {
304 // XXYY!! 304 // XXYY!!
305 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 305 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
@@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
314 public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) 314 public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient)
315 { 315 {
316 ScenePresence presence; 316 ScenePresence presence;
317 if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) 317 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
318 { 318 {
319 presence.Appearance.DetachAttachment(itemID); 319 presence.Appearance.DetachAttachment(itemID);
320 320
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 71b3062..f570999 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -388,7 +388,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
388 388
389 try 389 try
390 { 390 {
391 if (m_aScene.AuthenticationService.Authenticate(account.PrincipalID, pass, 1) != string.Empty) 391 string encpass = Util.Md5Hash(pass);
392 if (m_aScene.AuthenticationService.Authenticate(account.PrincipalID, encpass, 1) != string.Empty)
392 { 393 {
393 return account; 394 return account;
394 } 395 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 09552a8..7142442 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
358 { 358 {
359 ScenePresence presence; 359 ScenePresence presence;
360 360
361 if (s.TryGetAvatar(agentID, out presence)) 361 if (s.TryGetScenePresence(agentID, out presence))
362 { 362 {
363 // If the agent is in this scene, then we 363 // If the agent is in this scene, then we
364 // are being called twice in a single 364 // are being called twice in a single
diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs
index 63a93aa..c011776 100644
--- a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs
+++ b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
82 responsedata["str_response_string"] = "Request wasn't what was expected"; 82 responsedata["str_response_string"] = "Request wasn't what was expected";
83 ScenePresence avatar; 83 ScenePresence avatar;
84 84
85 if (!m_scene.TryGetAvatar(AgentId, out avatar)) 85 if (!m_scene.TryGetScenePresence(AgentId, out avatar))
86 return responsedata; 86 return responsedata;
87 87
88 88
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 25f5154..93aeb94 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -190,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
190 if (account == null) // foreign 190 if (account == null) // foreign
191 { 191 {
192 ScenePresence sp = null; 192 ScenePresence sp = null;
193 if (m_Scene.TryGetAvatar(userID, out sp)) 193 if (m_Scene.TryGetScenePresence(userID, out sp))
194 { 194 {
195 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 195 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
196 if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) 196 if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index 8cf4619..e95d2f8 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -1206,7 +1206,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
1206 { 1206 {
1207 Scene homeScene = GetRootScene(); 1207 Scene homeScene = GetRootScene();
1208 ScenePresence avatar = null; 1208 ScenePresence avatar = null;
1209 if (homeScene.TryGetAvatar(avatarId,out avatar)) 1209 if (homeScene.TryGetScenePresence(avatarId,out avatar))
1210 { 1210 {
1211 KillAUser ku = new KillAUser(avatar,mod); 1211 KillAUser ku = new KillAUser(avatar,mod);
1212 Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true); 1212 Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true);
diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
index 27b64bf..40ffcb4 100644
--- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
@@ -131,8 +131,8 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
131 { 131 {
132 // Start http server 132 // Start http server
133 // Attach xmlrpc handlers 133 // Attach xmlrpc handlers
134 m_log.Info("[REMOTE_DATA]: " + 134 m_log.Info("[XML RPC MODULE]: " +
135 "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); 135 "Starting up XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
136 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort); 136 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
137 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); 137 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
138 httpServer.Start(); 138 httpServer.Start();
@@ -192,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
192 // This should no longer happen, but the check is reasonable anyway 192 // This should no longer happen, but the check is reasonable anyway
193 if (null == m_openChannels) 193 if (null == m_openChannels)
194 { 194 {
195 m_log.Warn("[RemoteDataReply] Attempt to open channel before initialization is complete"); 195 m_log.Warn("[XML RPC MODULE]: Attempt to open channel before initialization is complete");
196 return newChannel; 196 return newChannel;
197 } 197 }
198 198
@@ -279,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
279 } 279 }
280 else 280 else
281 { 281 {
282 m_log.Warn("[RemoteDataReply]: Channel or message_id not found"); 282 m_log.Warn("[XML RPC MODULE]: Channel or message_id not found");
283 } 283 }
284 } 284 }
285 285
@@ -340,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
340 } 340 }
341 else 341 else
342 { 342 {
343 m_log.Error("UNABLE TO REMOVE COMPLETED REQUEST"); 343 m_log.Error("[XML RPC MODULE]: UNABLE TO REMOVE COMPLETED REQUEST");
344 } 344 }
345 } 345 }
346 } 346 }
@@ -728,4 +728,4 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
728 return ReqID; 728 return ReqID;
729 } 729 }
730 } 730 }
731} 731} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index c6312e0..54508cc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -502,7 +502,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
502 private UUID GetSessionID(UUID userID) 502 private UUID GetSessionID(UUID userID)
503 { 503 {
504 ScenePresence sp = null; 504 ScenePresence sp = null;
505 if (m_Scene.TryGetAvatar(userID, out sp)) 505 if (m_Scene.TryGetScenePresence(userID, out sp))
506 { 506 {
507 return sp.ControllingClient.SessionId; 507 return sp.ControllingClient.SessionId;
508 } 508 }
@@ -521,7 +521,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
521 if (account == null) // foreign user 521 if (account == null) // foreign user
522 { 522 {
523 ScenePresence sp = null; 523 ScenePresence sp = null;
524 m_Scene.TryGetAvatar(userID, out sp); 524 m_Scene.TryGetScenePresence(userID, out sp);
525 if (sp != null) 525 if (sp != null)
526 { 526 {
527 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 527 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
index 3c3534f..5e06580 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
100 ScenePresence sp = null; 100 ScenePresence sp = null;
101 foreach (Scene s in m_Scenes) 101 foreach (Scene s in m_Scenes)
102 { 102 {
103 s.TryGetAvatar(clientID, out sp); 103 s.TryGetScenePresence(clientID, out sp);
104 if ((sp != null) && !sp.IsChildAgent && (s != scene)) 104 if ((sp != null) && !sp.IsChildAgent && (s != scene))
105 { 105 {
106 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache", 106 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache",
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
index e98df28..7a75a89 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
88 Vector3 position = new Vector3(128, 128, 0); 88 Vector3 position = new Vector3(128, 128, 0);
89 Vector3 lookat = new Vector3(0, 1, 0); 89 Vector3 lookat = new Vector3(0, 1, 0);
90 90
91 if (client.Scene.TryGetAvatar(client.AgentId, out sp)) 91 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
92 { 92 {
93 if (sp is ScenePresence) 93 if (sp is ScenePresence)
94 { 94 {
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 464d922..91d40ab 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -468,26 +468,20 @@ namespace OpenSim.Region.CoreModules.World.Estate
468 468
469 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) 469 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
470 { 470 {
471 // Get a fresh list that will not change as people get teleported away 471 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
472 List<ScenePresence> presences = m_scene.GetScenePresences();
473
474 foreach(ScenePresence p in presences)
475 { 472 {
476 if (p.UUID != senderID) 473 if (sp.UUID != senderID)
477 { 474 {
475 ScenePresence p = m_scene.GetScenePresence(sp.UUID);
478 // make sure they are still there, we could be working down a long list 476 // make sure they are still there, we could be working down a long list
479 ScenePresence s = m_scene.GetScenePresence(p.UUID); 477 // Also make sure they are actually in the region
480 if (s != null) 478 if (p != null && !p.IsChildAgent)
481 { 479 {
482 // Also make sure they are actually in the region 480 p.ControllingClient.SendTeleportLocationStart();
483 if (!s.IsChildAgent) 481 m_scene.TeleportClientHome(p.UUID, p.ControllingClient);
484 {
485 s.ControllingClient.SendTeleportLocationStart();
486 m_scene.TeleportClientHome(s.UUID, s.ControllingClient);
487 }
488 } 482 }
489 } 483 }
490 } 484 });
491 } 485 }
492 private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) 486 private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
493 { 487 {
@@ -765,12 +759,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
765 759
766 public void sendRegionInfoPacketToAll() 760 public void sendRegionInfoPacketToAll()
767 { 761 {
768 List<ScenePresence> avatars = m_scene.GetAvatars(); 762 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
769
770 for (int i = 0; i < avatars.Count; i++)
771 { 763 {
772 HandleRegionInfoRequest(avatars[i].ControllingClient); 764 if (!sp.IsChildAgent)
773 } 765 HandleRegionInfoRequest(sp.ControllingClient);
766 });
774 } 767 }
775 768
776 public void sendRegionHandshake(IClientAPI remoteClient) 769 public void sendRegionHandshake(IClientAPI remoteClient)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index bf856c8..b6afac6 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -199,9 +199,9 @@ namespace OpenSim.Region.CoreModules.World.Land
199 forcedPosition = null; 199 forcedPosition = null;
200 } 200 }
201 //if we are far away, teleport 201 //if we are far away, teleport
202 else if (Vector3.Distance(clientAvatar.AbsolutePosition,forcedPosition.Value) > 3) 202 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition.Value) > 3)
203 { 203 {
204 Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}",forcedPosition.Value,clientAvatar.AbsolutePosition)); 204 Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}", forcedPosition.Value, clientAvatar.AbsolutePosition));
205 clientAvatar.Teleport(forcedPosition.Value); 205 clientAvatar.Teleport(forcedPosition.Value);
206 forcedPosition = null; 206 forcedPosition = null;
207 } 207 }
@@ -382,30 +382,27 @@ namespace OpenSim.Region.CoreModules.World.Land
382 } 382 }
383 } 383 }
384 384
385 public void SendOutNearestBanLine(IClientAPI avatar) 385 public void SendOutNearestBanLine(IClientAPI client)
386 { 386 {
387 List<ScenePresence> avatars = m_scene.GetAvatars(); 387 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
388 foreach (ScenePresence presence in avatars) 388 if (sp == null || sp.IsChildAgent)
389 return;
390
391 List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition);
392 foreach (ILandObject checkBan in checkLandParcels)
389 { 393 {
390 if (presence.UUID == avatar.AgentId) 394 if (checkBan.IsBannedFromLand(client.AgentId))
391 { 395 {
392 List<ILandObject> checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition); 396 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, client);
393 foreach (ILandObject checkBan in checkLandParcels) 397 return; //Only send one
394 { 398 }
395 if (checkBan.IsBannedFromLand(avatar.AgentId)) 399 if (checkBan.IsRestrictedFromLand(client.AgentId))
396 { 400 {
397 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar); 401 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, client);
398 return; //Only send one 402 return; //Only send one
399 }
400 if (checkBan.IsRestrictedFromLand(avatar.AgentId))
401 {
402 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar);
403 return; //Only send one
404 }
405 }
406 return;
407 } 403 }
408 } 404 }
405 return;
409 } 406 }
410 407
411 public void SendLandUpdate(ScenePresence avatar, bool force) 408 public void SendLandUpdate(ScenePresence avatar, bool force)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 331f183..aca5514 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -332,36 +332,38 @@ namespace OpenSim.Region.CoreModules.World.Land
332 332
333 public void SendLandUpdateToAvatarsOverMe(bool snap_selection) 333 public void SendLandUpdateToAvatarsOverMe(bool snap_selection)
334 { 334 {
335 List<ScenePresence> avatars = m_scene.GetAvatars(); 335 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
336 ILandObject over = null;
337 for (int i = 0; i < avatars.Count; i++)
338 { 336 {
337 if (avatar.IsChildAgent)
338 return;
339
340 ILandObject over = null;
339 try 341 try
340 { 342 {
341 over = 343 over =
342 m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), 344 m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)),
343 Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); 345 Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1)));
344 } 346 }
345 catch (Exception) 347 catch (Exception)
346 { 348 {
347 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + 349 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " +
348 Math.Round(avatars[i].AbsolutePosition.Y)); 350 Math.Round(avatar.AbsolutePosition.Y));
349 } 351 }
350 352
351 if (over != null) 353 if (over != null)
352 { 354 {
353 if (over.LandData.LocalID == LandData.LocalID) 355 if (over.LandData.LocalID == LandData.LocalID)
354 { 356 {
355 if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) && 357 if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) &&
356 m_scene.RegionInfo.RegionSettings.AllowDamage) 358 m_scene.RegionInfo.RegionSettings.AllowDamage)
357 avatars[i].Invulnerable = false; 359 avatar.Invulnerable = false;
358 else 360 else
359 avatars[i].Invulnerable = true; 361 avatar.Invulnerable = true;
360 362
361 SendLandUpdateToClient(snap_selection, avatars[i].ControllingClient); 363 SendLandUpdateToClient(snap_selection, avatar.ControllingClient);
362 } 364 }
363 } 365 }
364 } 366 });
365 } 367 }
366 368
367 #endregion 369 #endregion
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 4dbdb01..0f830e1 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -1324,9 +1324,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1324 1324
1325 // Group voodoo 1325 // Group voodoo
1326 // 1326 //
1327 if (land.LandData.IsGroupOwned) 1327 if (l.LandData.IsGroupOwned)
1328 { 1328 {
1329 powers = (GroupPowers)client.GetGroupPowers(land.LandData.GroupID); 1329 powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID);
1330 // Not a group member, or no rights at all 1330 // Not a group member, or no rights at all
1331 // 1331 //
1332 if (powers == (GroupPowers)0) 1332 if (powers == (GroupPowers)0)
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 1f5a4ff..a52fea4 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -62,40 +62,46 @@ namespace OpenSim.Region.CoreModules.World.Sound
62 public virtual void PlayAttachedSound( 62 public virtual void PlayAttachedSound(
63 UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) 63 UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius)
64 { 64 {
65 foreach (ScenePresence p in m_scene.GetAvatars()) 65 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
66 { 66 {
67 double dis = Util.GetDistanceTo(p.AbsolutePosition, position); 67 if (sp.IsChildAgent)
68 return;
69
70 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
68 if (dis > 100.0) // Max audio distance 71 if (dis > 100.0) // Max audio distance
69 continue; 72 return;
70 73
71 // Scale by distance 74 // Scale by distance
72 if (radius == 0) 75 if (radius == 0)
73 gain = (float)((double)gain * ((100.0 - dis) / 100.0)); 76 gain = (float)((double)gain * ((100.0 - dis) / 100.0));
74 else 77 else
75 gain = (float)((double)gain * ((radius - dis) / radius)); 78 gain = (float)((double)gain * ((radius - dis) / radius));
76 79
77 p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); 80 sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags);
78 } 81 });
79 } 82 }
80 83
81 public virtual void TriggerSound( 84 public virtual void TriggerSound(
82 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) 85 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius)
83 { 86 {
84 foreach (ScenePresence p in m_scene.GetAvatars()) 87 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
85 { 88 {
86 double dis = Util.GetDistanceTo(p.AbsolutePosition, position); 89 if (sp.IsChildAgent)
90 return;
91
92 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
87 if (dis > 100.0) // Max audio distance 93 if (dis > 100.0) // Max audio distance
88 continue; 94 return;
89 95
90 // Scale by distance 96 // Scale by distance
91 if (radius == 0) 97 if (radius == 0)
92 gain = (float)((double)gain * ((100.0 - dis) / 100.0)); 98 gain = (float)((double)gain * ((100.0 - dis) / 100.0));
93 else 99 else
94 gain = (float)((double)gain * ((radius - dis) / radius)); 100 gain = (float)((double)gain * ((radius - dis) / radius));
95 101
96 p.ControllingClient.SendTriggeredSound( 102 sp.ControllingClient.SendTriggeredSound(
97 soundId, ownerID, objectID, parentID, handle, position, (float)gain); 103 soundId, ownerID, objectID, parentID, handle, position, (float)gain);
98 } 104 });
99 } 105 }
100 } 106 }
101} 107}
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index 0712a7f..a6dc2ec 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -509,14 +509,13 @@ namespace OpenSim.Region.CoreModules
509 509
510 private void SunUpdateToAllClients() 510 private void SunUpdateToAllClients()
511 { 511 {
512 List<ScenePresence> avatars = m_scene.GetAvatars(); 512 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
513 foreach (ScenePresence avatar in avatars)
514 { 513 {
515 if (!avatar.IsChildAgent) 514 if (!sp.IsChildAgent)
516 { 515 {
517 SunToClient(avatar.ControllingClient); 516 SunToClient(sp.ControllingClient);
518 } 517 }
519 } 518 });
520 } 519 }
521 520
522 #region ISunModule Members 521 #region ISunModule Members
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
index 3283c1f..9736b73 100644
--- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
+++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
@@ -425,9 +425,7 @@ namespace OpenSim.Region.CoreModules
425 { 425 {
426 if (m_ready) 426 if (m_ready)
427 { 427 {
428 List<ScenePresence> avatars = m_scene.GetAvatars(); 428 if(m_scene.GetRootAgentCount() > 0)
429
430 if (avatars.Count > 0)
431 { 429 {
432 // Ask wind plugin to generate a LL wind array to be cached locally 430 // Ask wind plugin to generate a LL wind array to be cached locally
433 // Try not to update this too often, as it may involve array copies 431 // Try not to update this too often, as it may involve array copies
@@ -437,11 +435,11 @@ namespace OpenSim.Region.CoreModules
437 m_frameLastUpdateClientArray = m_frame; 435 m_frameLastUpdateClientArray = m_frame;
438 } 436 }
439 437
440 foreach (ScenePresence avatar in avatars) 438 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
441 { 439 {
442 if (!avatar.IsChildAgent) 440 if (!sp.IsChildAgent)
443 avatar.ControllingClient.SendWindData(windSpeeds); 441 sp.ControllingClient.SendWindData(windSpeeds);
444 } 442 });
445 } 443 }
446 } 444 }
447 } 445 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index b63d014..2b0e83f 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
210 // this is here because CAPS map requests work even beyond the 10,000 limit. 210 // this is here because CAPS map requests work even beyond the 10,000 limit.
211 ScenePresence avatarPresence = null; 211 ScenePresence avatarPresence = null;
212 212
213 m_scene.TryGetAvatar(agentID, out avatarPresence); 213 m_scene.TryGetScenePresence(agentID, out avatarPresence);
214 214
215 if (avatarPresence != null) 215 if (avatarPresence != null)
216 { 216 {
@@ -304,25 +304,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
304 /// <param name="AgentId">AgentID that logged out</param> 304 /// <param name="AgentId">AgentID that logged out</param>
305 private void ClientLoggedOut(UUID AgentId, Scene scene) 305 private void ClientLoggedOut(UUID AgentId, Scene scene)
306 { 306 {
307 List<ScenePresence> presences = m_scene.GetAvatars();
308 int rootcount = 0;
309 for (int i=0;i<presences.Count;i++)
310 {
311 if (presences[i] != null)
312 {
313 if (!presences[i].IsChildAgent)
314 rootcount++;
315 }
316 }
317 if (rootcount <= 1)
318 StopThread();
319
320 lock (m_rootAgents) 307 lock (m_rootAgents)
321 { 308 {
322 if (m_rootAgents.Contains(AgentId)) 309 m_rootAgents.Remove(AgentId);
323 { 310 if(m_rootAgents.Count == 0)
324 m_rootAgents.Remove(AgentId); 311 StopThread();
325 }
326 } 312 }
327 } 313 }
328 #endregion 314 #endregion
@@ -375,11 +361,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
375 if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) 361 if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
376 { 362 {
377 // Local Map Item Request 363 // Local Map Item Request
378 List<ScenePresence> avatars = m_scene.GetAvatars();
379 int tc = Environment.TickCount; 364 int tc = Environment.TickCount;
380 List<mapItemReply> mapitems = new List<mapItemReply>(); 365 List<mapItemReply> mapitems = new List<mapItemReply>();
381 mapItemReply mapitem = new mapItemReply(); 366 mapItemReply mapitem = new mapItemReply();
382 if (avatars.Count == 0 || avatars.Count == 1) 367 if (m_scene.GetRootAgentCount() <= 1)
383 { 368 {
384 mapitem = new mapItemReply(); 369 mapitem = new mapItemReply();
385 mapitem.x = (uint)(xstart + 1); 370 mapitem.x = (uint)(xstart + 1);
@@ -392,21 +377,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
392 } 377 }
393 else 378 else
394 { 379 {
395 foreach (ScenePresence av in avatars) 380 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
396 { 381 {
397 // Don't send a green dot for yourself 382 // Don't send a green dot for yourself
398 if (av.UUID != remoteClient.AgentId) 383 if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId)
399 { 384 {
400 mapitem = new mapItemReply(); 385 mapitem = new mapItemReply();
401 mapitem.x = (uint)(xstart + av.AbsolutePosition.X); 386 mapitem.x = (uint)(xstart + sp.AbsolutePosition.X);
402 mapitem.y = (uint)(ystart + av.AbsolutePosition.Y); 387 mapitem.y = (uint)(ystart + sp.AbsolutePosition.Y);
403 mapitem.id = UUID.Zero; 388 mapitem.id = UUID.Zero;
404 mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()); 389 mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
405 mapitem.Extra = 1; 390 mapitem.Extra = 1;
406 mapitem.Extra2 = 0; 391 mapitem.Extra2 = 0;
407 mapitems.Add(mapitem); 392 mapitems.Add(mapitem);
408 } 393 }
409 } 394 });
410 } 395 }
411 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); 396 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
412 } 397 }
@@ -504,7 +489,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
504 if (mrs.agentID != UUID.Zero) 489 if (mrs.agentID != UUID.Zero)
505 { 490 {
506 ScenePresence av = null; 491 ScenePresence av = null;
507 m_scene.TryGetAvatar(mrs.agentID, out av); 492 m_scene.TryGetScenePresence(mrs.agentID, out av);
508 if (av != null) 493 if (av != null)
509 { 494 {
510 if (response.ContainsKey(mrs.itemtype.ToString())) 495 if (response.ContainsKey(mrs.itemtype.ToString()))
@@ -981,51 +966,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
981 Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); 966 Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);
982 967
983 OSDMap responsemap = new OSDMap(); 968 OSDMap responsemap = new OSDMap();
984 List<ScenePresence> avatars = m_scene.GetAvatars();
985 OSDArray responsearr = new OSDArray(avatars.Count);
986 OSDMap responsemapdata = new OSDMap();
987 int tc = Environment.TickCount; 969 int tc = Environment.TickCount;
988 /* 970 if (m_scene.GetRootAgentCount() == 0)
989 foreach (ScenePresence av in avatars)
990 {
991 responsemapdata = new OSDMap();
992 responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
993 responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
994 responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
995 responsemapdata["Name"] = OSD.FromString("TH");
996 responsemapdata["Extra"] = OSD.FromInteger(0);
997 responsemapdata["Extra2"] = OSD.FromInteger(0);
998 responsearr.Add(responsemapdata);
999 }
1000 responsemap["1"] = responsearr;
1001 */
1002 if (avatars.Count == 0)
1003 { 971 {
1004 responsemapdata = new OSDMap(); 972 OSDMap responsemapdata = new OSDMap();
1005 responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1)); 973 responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
1006 responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1)); 974 responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
1007 responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); 975 responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
1008 responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString())); 976 responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
1009 responsemapdata["Extra"] = OSD.FromInteger(0); 977 responsemapdata["Extra"] = OSD.FromInteger(0);
1010 responsemapdata["Extra2"] = OSD.FromInteger(0); 978 responsemapdata["Extra2"] = OSD.FromInteger(0);
979 OSDArray responsearr = new OSDArray();
1011 responsearr.Add(responsemapdata); 980 responsearr.Add(responsemapdata);
1012 981
1013 responsemap["6"] = responsearr; 982 responsemap["6"] = responsearr;
1014 } 983 }
1015 else 984 else
1016 { 985 {
1017 responsearr = new OSDArray(avatars.Count); 986 OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
1018 foreach (ScenePresence av in avatars) 987 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
1019 { 988 {
1020 responsemapdata = new OSDMap(); 989 OSDMap responsemapdata = new OSDMap();
1021 responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X)); 990 responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
1022 responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y)); 991 responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sp.AbsolutePosition.Y));
1023 responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); 992 responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
1024 responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString())); 993 responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
1025 responsemapdata["Extra"] = OSD.FromInteger(1); 994 responsemapdata["Extra"] = OSD.FromInteger(1);
1026 responsemapdata["Extra2"] = OSD.FromInteger(0); 995 responsemapdata["Extra2"] = OSD.FromInteger(0);
1027 responsearr.Add(responsemapdata); 996 responsearr.Add(responsemapdata);
1028 } 997 });
1029 responsemap["6"] = responsearr; 998 responsemap["6"] = responsearr;
1030 } 999 }
1031 return responsemap; 1000 return responsemap;
@@ -1107,25 +1076,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1107 1076
1108 private void MakeChildAgent(ScenePresence avatar) 1077 private void MakeChildAgent(ScenePresence avatar)
1109 { 1078 {
1110 List<ScenePresence> presences = m_scene.GetAvatars();
1111 int rootcount = 0;
1112 for (int i = 0; i < presences.Count; i++)
1113 {
1114 if (presences[i] != null)
1115 {
1116 if (!presences[i].IsChildAgent)
1117 rootcount++;
1118 }
1119 }
1120 if (rootcount <= 1)
1121 StopThread();
1122
1123 lock (m_rootAgents) 1079 lock (m_rootAgents)
1124 { 1080 {
1125 if (m_rootAgents.Contains(avatar.UUID)) 1081 m_rootAgents.Remove(avatar.UUID);
1126 { 1082 if (m_rootAgents.Count == 0)
1127 m_rootAgents.Remove(avatar.UUID); 1083 StopThread();
1128 }
1129 } 1084 }
1130 } 1085 }
1131 1086
diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
index e1d5bdc..6da41db 100644
--- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
+++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
@@ -88,12 +88,12 @@ namespace OpenSim.Region.Examples.SimpleModule
88 m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false); 88 m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false);
89 } 89 }
90 90
91 List<ScenePresence> avatars = m_scene.GetAvatars(); 91 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
92 foreach (ScenePresence avatar in avatars)
93 { 92 {
94 avatar.AbsolutePosition = 93 if (!sp.IsChildAgent)
95 new Vector3((float)Util.RandomClass.Next(100, 200), (float)Util.RandomClass.Next(30, 200), 2); 94 sp.AbsolutePosition =
96 } 95 new Vector3((float)Util.RandomClass.Next(100, 200), (float)Util.RandomClass.Next(30, 200), 2);
96 });
97 } 97 }
98 98
99 // private void AddComplexObjects(RegionInfo regionInfo, Vector3 pos) 99 // private void AddComplexObjects(RegionInfo regionInfo, Vector3 pos)
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
index 668ff98..87c7a05 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenSim.Framework;
30 31
@@ -34,7 +35,12 @@ namespace OpenSim.Region.Framework.Interfaces
34 { 35 {
35 void Initialise(string connectstring); 36 void Initialise(string connectstring);
36 37
37 EstateSettings LoadEstateSettings(UUID regionID); 38 EstateSettings LoadEstateSettings(UUID regionID, bool create);
39 EstateSettings LoadEstateSettings(int estateID);
38 void StoreEstateSettings(EstateSettings es); 40 void StoreEstateSettings(EstateSettings es);
41 List<int> GetEstates(string search);
42 bool LinkRegion(UUID regionID, int estateID);
43 List<UUID> GetRegions(int estateID);
44 bool DeleteEstate(int estateID);
39 } 45 }
40} 46}
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
index 8980b2d..2c091e7 100644
--- a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
@@ -37,21 +37,51 @@ namespace OpenSim.Region.Framework.Interfaces
37 { 37 {
38 event NewGroupNotice OnNewGroupNotice; 38 event NewGroupNotice OnNewGroupNotice;
39 39
40 /// <summary>
41 /// Create a group
42 /// </summary>
43 /// <param name="remoteClient"></param>
44 /// <param name="name"></param>
45 /// <param name="charter"></param>
46 /// <param name="showInList"></param>
47 /// <param name="insigniaID"></param>
48 /// <param name="membershipFee"></param>
49 /// <param name="openEnrollment"></param>
50 /// <param name="allowPublish"></param>
51 /// <param name="maturePublish"></param>
52 /// <returns>The UUID of the created group</returns>
53 UUID CreateGroup(
54 IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee,
55 bool openEnrollment, bool allowPublish, bool maturePublish);
56
57 /// <summary>
58 /// Get a group
59 /// </summary>
60 /// <param name="name">Name of the group</param>
61 /// <returns>The group's data. Null if there is no such group.</returns>
62 GroupRecord GetGroupRecord(string name);
63
64 /// <summary>
65 /// Get a group
66 /// </summary>
67 /// <param name="GroupID">ID of the group</param>
68 /// <returns>The group's data. Null if there is no such group.</returns>
69 GroupRecord GetGroupRecord(UUID GroupID);
70
40 void ActivateGroup(IClientAPI remoteClient, UUID groupID); 71 void ActivateGroup(IClientAPI remoteClient, UUID groupID);
41 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID); 72 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID);
42 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID); 73 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID);
43 List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID); 74 List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID);
44 List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID); 75 List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID);
45 GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID); 76 GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID);
46 GroupMembershipData[] GetMembershipData(UUID UserID); 77 GroupMembershipData[] GetMembershipData(UUID UserID);
47 GroupMembershipData GetMembershipData(UUID GroupID, UUID UserID); 78 GroupMembershipData GetMembershipData(UUID GroupID, UUID UserID);
48 79
49 void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); 80 void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
50 81
51 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile); 82 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile);
52 83
53 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID); 84 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID);
54 UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
55 85
56 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID); 86 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID);
57 string GetGroupTitle(UUID avatarID); 87 string GetGroupTitle(UUID avatarID);
@@ -64,7 +94,6 @@ namespace OpenSim.Region.Framework.Interfaces
64 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID); 94 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID);
65 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID); 95 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID);
66 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID); 96 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID);
67 GroupRecord GetGroupRecord(UUID GroupID);
68 void NotifyChange(UUID GroupID); 97 void NotifyChange(UUID GroupID);
69 } 98 }
70} 99} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index cadb858..1875c48 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -132,7 +132,7 @@ namespace OpenSim.Region.Framework.Scenes
132 { 132 {
133 ScenePresence avatar; 133 ScenePresence avatar;
134 134
135 if (TryGetAvatar(avatarId, out avatar)) 135 if (TryGetScenePresence(avatarId, out avatar))
136 { 136 {
137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
138 if (invAccess != null) 138 if (invAccess != null)
@@ -230,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
230 { 230 {
231 ScenePresence avatar; 231 ScenePresence avatar;
232 232
233 if (TryGetAvatar(avatarId, out avatar)) 233 if (TryGetScenePresence(avatarId, out avatar))
234 { 234 {
235 return CapsUpdateTaskInventoryScriptAsset( 235 return CapsUpdateTaskInventoryScriptAsset(
236 avatar.ControllingClient, itemId, primId, isScriptRunning, data); 236 avatar.ControllingClient, itemId, primId, isScriptRunning, data);
@@ -683,7 +683,7 @@ namespace OpenSim.Region.Framework.Scenes
683 if (transactionID == UUID.Zero) 683 if (transactionID == UUID.Zero)
684 { 684 {
685 ScenePresence presence; 685 ScenePresence presence;
686 if (TryGetAvatar(remoteClient.AgentId, out presence)) 686 if (TryGetScenePresence(remoteClient.AgentId, out presence))
687 { 687 {
688 byte[] data = null; 688 byte[] data = null;
689 689
@@ -945,7 +945,7 @@ namespace OpenSim.Region.Framework.Scenes
945 { 945 {
946 ScenePresence avatar; 946 ScenePresence avatar;
947 947
948 if (TryGetAvatar(avatarId, out avatar)) 948 if (TryGetScenePresence(avatarId, out avatar))
949 { 949 {
950 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); 950 return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
951 } 951 }
@@ -1059,7 +1059,7 @@ namespace OpenSim.Region.Framework.Scenes
1059 1059
1060 ScenePresence avatar; 1060 ScenePresence avatar;
1061 1061
1062 if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) 1062 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1063 { 1063 {
1064 destPart.GetProperties(avatar.ControllingClient); 1064 destPart.GetProperties(avatar.ControllingClient);
1065 } 1065 }
@@ -1087,7 +1087,7 @@ namespace OpenSim.Region.Framework.Scenes
1087 } 1087 }
1088 1088
1089 ScenePresence avatar = null; 1089 ScenePresence avatar = null;
1090 if (TryGetAvatar(destID, out avatar)) 1090 if (TryGetScenePresence(destID, out avatar))
1091 { 1091 {
1092 //profile.SendInventoryDecendents(avatar.ControllingClient, 1092 //profile.SendInventoryDecendents(avatar.ControllingClient,
1093 // profile.RootFolder.ID, true, false); 1093 // profile.RootFolder.ID, true, false);
@@ -1424,7 +1424,7 @@ namespace OpenSim.Region.Framework.Scenes
1424 1424
1425 ScenePresence avatar; 1425 ScenePresence avatar;
1426 1426
1427 if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) 1427 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1428 { 1428 {
1429 destPart.GetProperties(avatar.ControllingClient); 1429 destPart.GetProperties(avatar.ControllingClient);
1430 } 1430 }
@@ -1865,7 +1865,7 @@ namespace OpenSim.Region.Framework.Scenes
1865 UUID inventoryID = part.ParentGroup.GetFromItemID(); 1865 UUID inventoryID = part.ParentGroup.GetFromItemID();
1866 1866
1867 ScenePresence presence; 1867 ScenePresence presence;
1868 if (TryGetAvatar(remoteClient.AgentId, out presence)) 1868 if (TryGetScenePresence(remoteClient.AgentId, out presence))
1869 { 1869 {
1870 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) 1870 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
1871 return; 1871 return;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index b2c8dfd..2b6f80b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -606,7 +606,46 @@ namespace OpenSim.Region.Framework.Scenes
606 606
607 if (m_storageManager.EstateDataStore != null) 607 if (m_storageManager.EstateDataStore != null)
608 { 608 {
609 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); 609 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false);
610 if (m_regInfo.EstateSettings.EstateID == 0) // No record at all
611 {
612 MainConsole.Instance.Output("Your region is not part of an estate.");
613 while (true)
614 {
615 string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"});
616 if (response == "no")
617 {
618 // Create a new estate
619 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true);
620
621 m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName);
622 m_regInfo.EstateSettings.Save();
623 break;
624 }
625 else
626 {
627 response = MainConsole.Instance.CmdPrompt("Estate name to join", "None");
628 if (response == "None")
629 continue;
630
631 List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response);
632 if (estateIDs.Count < 1)
633 {
634 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again");
635 continue;
636 }
637
638 int estateID = estateIDs[0];
639
640 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID);
641
642 if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID))
643 break;
644
645 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
646 }
647 }
648 }
610 } 649 }
611 650
612 //Bind Storage Manager functions to some land manager functions for this scene 651 //Bind Storage Manager functions to some land manager functions for this scene
@@ -1229,6 +1268,84 @@ namespace OpenSim.Region.Framework.Scenes
1229 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1268 m_dialogModule = RequestModuleInterface<IDialogModule>();
1230 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1269 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1231 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1270 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1271
1272 // Shoving this in here for now, because we have the needed
1273 // interfaces at this point
1274 //
1275 // TODO: Find a better place for this
1276 //
1277 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
1278 {
1279 MainConsole.Instance.Output("The current estate has no owner set.");
1280 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test");
1281 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User");
1282
1283 UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last);
1284
1285 if (account == null)
1286 {
1287 // Create a new account
1288 account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty);
1289 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
1290 {
1291 account.ServiceURLs = new Dictionary<string, object>();
1292 account.ServiceURLs["HomeURI"] = string.Empty;
1293 account.ServiceURLs["GatekeeperURI"] = string.Empty;
1294 account.ServiceURLs["InventoryServerURI"] = string.Empty;
1295 account.ServiceURLs["AssetServerURI"] = string.Empty;
1296 }
1297
1298 if (UserAccountService.StoreUserAccount(account))
1299 {
1300 string password = MainConsole.Instance.PasswdPrompt("Password");
1301 string email = MainConsole.Instance.CmdPrompt("Email", "");
1302
1303 account.Email = email;
1304 UserAccountService.StoreUserAccount(account);
1305
1306 bool success = false;
1307 success = AuthenticationService.SetPassword(account.PrincipalID, password);
1308 if (!success)
1309 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
1310 first, last);
1311
1312 GridRegion home = null;
1313 if (GridService != null)
1314 {
1315 List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero);
1316 if (defaultRegions != null && defaultRegions.Count >= 1)
1317 home = defaultRegions[0];
1318
1319 if (PresenceService != null && home != null)
1320 PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1321 else
1322 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
1323 first, last);
1324
1325 }
1326 else
1327 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
1328 first, last);
1329
1330 if (InventoryService != null)
1331 success = InventoryService.CreateUserInventory(account.PrincipalID);
1332 if (!success)
1333 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
1334 first, last);
1335
1336
1337 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last);
1338
1339 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1340 m_regInfo.EstateSettings.Save();
1341 }
1342 }
1343 else
1344 {
1345 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1346 m_regInfo.EstateSettings.Save();
1347 }
1348 }
1232 } 1349 }
1233 1350
1234 #endregion 1351 #endregion
@@ -3296,7 +3413,7 @@ namespace OpenSim.Region.Framework.Scenes
3296 } 3413 }
3297 } 3414 }
3298 3415
3299 ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); 3416 ScenePresence sp = GetScenePresence(agent.AgentID);
3300 if (sp != null) 3417 if (sp != null)
3301 { 3418 {
3302 m_log.DebugFormat( 3419 m_log.DebugFormat(
@@ -3594,8 +3711,7 @@ namespace OpenSim.Region.Framework.Scenes
3594 /// <param name="message">message to display to the user. Reason for being logged off</param> 3711 /// <param name="message">message to display to the user. Reason for being logged off</param>
3595 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) 3712 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3596 { 3713 {
3597 ScenePresence loggingOffUser = null; 3714 ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3598 loggingOffUser = GetScenePresence(AvatarID);
3599 if (loggingOffUser != null) 3715 if (loggingOffUser != null)
3600 { 3716 {
3601 UUID localRegionSecret = UUID.Zero; 3717 UUID localRegionSecret = UUID.Zero;
@@ -3631,8 +3747,8 @@ namespace OpenSim.Region.Framework.Scenes
3631 /// <param name="isFlying"></param> 3747 /// <param name="isFlying"></param>
3632 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3748 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3633 { 3749 {
3634 ScenePresence presence; 3750 ScenePresence presence = GetScenePresence(agentID);
3635 if(m_sceneGraph.TryGetAvatar(agentID, out presence)) 3751 if(presence != null)
3636 { 3752 {
3637 try 3753 try
3638 { 3754 {
@@ -3806,8 +3922,8 @@ namespace OpenSim.Region.Framework.Scenes
3806 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, 3922 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
3807 Vector3 lookAt, uint teleportFlags) 3923 Vector3 lookAt, uint teleportFlags)
3808 { 3924 {
3809 ScenePresence sp; 3925 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
3810 if(m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp)) 3926 if (sp != null)
3811 { 3927 {
3812 uint regionX = m_regInfo.RegionLocX; 3928 uint regionX = m_regInfo.RegionLocX;
3813 uint regionY = m_regInfo.RegionLocY; 3929 uint regionY = m_regInfo.RegionLocY;
@@ -3985,17 +4101,17 @@ namespace OpenSim.Region.Framework.Scenes
3985 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", 4101 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname",
3986 "Agent ID", "Session ID", "Circuit", "IP", "World"); 4102 "Agent ID", "Session ID", "Circuit", "IP", "World");
3987 4103
3988 foreach (ScenePresence scenePresence in GetAvatars()) 4104 ForEachScenePresence(delegate(ScenePresence sp)
3989 { 4105 {
3990 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", 4106 m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
3991 scenePresence.Firstname, 4107 sp.Firstname,
3992 scenePresence.Lastname, 4108 sp.Lastname,
3993 scenePresence.UUID, 4109 sp.UUID,
3994 scenePresence.ControllingClient.AgentId, 4110 sp.ControllingClient.AgentId,
3995 "Unknown", 4111 "Unknown",
3996 "Unknown", 4112 "Unknown",
3997 RegionInfo.RegionName); 4113 RegionInfo.RegionName);
3998 } 4114 });
3999 4115
4000 break; 4116 break;
4001 } 4117 }
@@ -4161,72 +4277,42 @@ namespace OpenSim.Region.Framework.Scenes
4161 m_sceneGraph.RemovePhysicalPrim(num); 4277 m_sceneGraph.RemovePhysicalPrim(num);
4162 } 4278 }
4163 4279
4164 //The idea is to have a group of method that return a list of avatars meeting some requirement 4280 public int GetRootAgentCount()
4165 // ie it could be all m_scenePresences within a certain range of the calling prim/avatar.
4166 //
4167 // GetAvatars returns a new list of all root agent presences in the scene
4168 // GetScenePresences returns a new list of all presences in the scene or a filter may be passed.
4169 // GetScenePresence returns the presence with matching UUID or first/last name.
4170 // ForEachScenePresence requests the Scene to run a delegate function against all presences.
4171
4172 /// <summary>
4173 /// Return a list of all avatars in this region.
4174 /// This list is a new object, so it can be iterated over without locking.
4175 /// </summary>
4176 /// <returns></returns>
4177 public List<ScenePresence> GetAvatars()
4178 { 4281 {
4179 return m_sceneGraph.GetAvatars(); 4282 return m_sceneGraph.GetRootAgentCount();
4180 } 4283 }
4181 4284
4182 /// <summary> 4285 public int GetChildAgentCount()
4183 /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents.
4184 /// This list is a new object, so it can be iterated over without locking.
4185 /// </summary>
4186 /// <returns></returns>
4187 public List<ScenePresence> GetScenePresences()
4188 { 4286 {
4189 return m_sceneGraph.GetScenePresences(); 4287 return m_sceneGraph.GetChildAgentCount();
4190 } 4288 }
4191 4289
4192 /// <summary> 4290 /// <summary>
4193 /// Request a filtered list of ScenePresences in this region. 4291 /// Request a scene presence by UUID. Fast, indexed lookup.
4194 /// This list is a new object, so it can be iterated over without locking.
4195 /// </summary> 4292 /// </summary>
4196 /// <param name="filter"></param> 4293 /// <param name="agentID"></param>
4197 /// <returns></returns> 4294 /// <returns>null if the presence was not found</returns>
4198 public List<ScenePresence> GetScenePresences(FilterAvatarList filter) 4295 public ScenePresence GetScenePresence(UUID agentID)
4199 {
4200 return m_sceneGraph.GetScenePresences(filter);
4201 }
4202
4203 /// <summary>
4204 /// Request a scene presence by UUID
4205 /// </summary>
4206 /// <param name="avatarID"></param>
4207 /// <returns></returns>
4208 public ScenePresence GetScenePresence(UUID avatarID)
4209 { 4296 {
4210 return m_sceneGraph.GetScenePresence(avatarID); 4297 return m_sceneGraph.GetScenePresence(agentID);
4211 } 4298 }
4212 4299
4213 /// <summary> 4300 /// <summary>
4214 /// Request the ScenePresence in this region by first/last name. 4301 /// Request the scene presence by name.
4215 /// Should normally only be a single match, but first is always returned
4216 /// </summary> 4302 /// </summary>
4217 /// <param name="firstName"></param> 4303 /// <param name="firstName"></param>
4218 /// <param name="lastName"></param> 4304 /// <param name="lastName"></param>
4219 /// <returns></returns> 4305 /// <returns>null if the presence was not found</returns>
4220 public ScenePresence GetScenePresence(string firstName, string lastName) 4306 public ScenePresence GetScenePresence(string firstName, string lastName)
4221 { 4307 {
4222 return m_sceneGraph.GetScenePresence(firstName, lastName); 4308 return m_sceneGraph.GetScenePresence(firstName, lastName);
4223 } 4309 }
4224 4310
4225 /// <summary> 4311 /// <summary>
4226 /// Request the ScenePresence in this region by localID. 4312 /// Request the scene presence by localID.
4227 /// </summary> 4313 /// </summary>
4228 /// <param name="localID"></param> 4314 /// <param name="localID"></param>
4229 /// <returns></returns> 4315 /// <returns>null if the presence was not found</returns>
4230 public ScenePresence GetScenePresence(uint localID) 4316 public ScenePresence GetScenePresence(uint localID)
4231 { 4317 {
4232 return m_sceneGraph.GetScenePresence(localID); 4318 return m_sceneGraph.GetScenePresence(localID);
@@ -4318,9 +4404,9 @@ namespace OpenSim.Region.Framework.Scenes
4318 return m_sceneGraph.GetGroupByPrim(localID); 4404 return m_sceneGraph.GetGroupByPrim(localID);
4319 } 4405 }
4320 4406
4321 public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 4407 public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
4322 { 4408 {
4323 return m_sceneGraph.TryGetAvatar(avatarId, out avatar); 4409 return m_sceneGraph.TryGetScenePresence(avatarId, out avatar);
4324 } 4410 }
4325 4411
4326 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 4412 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 74476ed..3218dad 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -190,11 +190,11 @@ namespace OpenSim.Region.Framework.Scenes
190 /// <param name="agentID"></param> 190 /// <param name="agentID"></param>
191 public abstract void RemoveClient(UUID agentID); 191 public abstract void RemoveClient(UUID agentID);
192 192
193 public bool TryGetAvatar(UUID agentID, out object scenePresence) 193 public bool TryGetScenePresence(UUID agentID, out object scenePresence)
194 { 194 {
195 scenePresence = null; 195 scenePresence = null;
196 ScenePresence sp = null; 196 ScenePresence sp = null;
197 if (TryGetAvatar(agentID, out sp)) 197 if (TryGetScenePresence(agentID, out sp))
198 { 198 {
199 scenePresence = sp; 199 scenePresence = sp;
200 return true; 200 return true;
@@ -203,7 +203,7 @@ namespace OpenSim.Region.Framework.Scenes
203 return false; 203 return false;
204 } 204 }
205 205
206 public abstract bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence); 206 public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence);
207 207
208 #endregion 208 #endregion
209 209
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 19298d2..3a1962c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -723,116 +723,84 @@ namespace OpenSim.Region.Framework.Scenes
723 return null; 723 return null;
724 } 724 }
725 725
726 // The idea is to have a group of method that return a list of avatars meeting some requirement
727 // ie it could be all m_scenePresences within a certain range of the calling prim/avatar.
728 //
729 // GetAvatars returns a new list of all root agent presences in the scene
730 // GetScenePresences returns a new list of all presences in the scene or a filter may be passed.
731 // GetScenePresence returns the presence with matching UUID or the first presence matching the passed filter.
732 // ForEachScenePresence requests the Scene to run a delegate function against all presences.
733
734 /// <summary> 726 /// <summary>
735 /// Request a list of all avatars in this region (no child agents) 727 /// Request a copy of m_scenePresences in this World
736 /// This list is a new object, so it can be iterated over without locking. 728 /// There is no guarantee that presences will remain in the scene after the list is returned.
729 /// This list should remain private to SceneGraph. Callers wishing to iterate should instead
730 /// pass a delegate to ForEachScenePresence.
737 /// </summary> 731 /// </summary>
738 /// <returns></returns> 732 /// <returns></returns>
739 public List<ScenePresence> GetAvatars() 733 private List<ScenePresence> GetScenePresences()
740 { 734 {
741 return GetScenePresences(delegate(ScenePresence scenePresence) 735 lock (m_scenePresences)
742 { 736 return new List<ScenePresence>(m_scenePresenceArray);
743 return !scenePresence.IsChildAgent;
744 });
745 } 737 }
746 738
747 /// <summary> 739 /// <summary>
748 /// Request a list of m_scenePresences in this World 740 /// Request a scene presence by UUID. Fast, indexed lookup.
749 /// Returns a copy so it can be iterated without a lock.
750 /// There is no guarantee that presences will remain in the scene after the list is returned.
751 /// </summary> 741 /// </summary>
752 /// <returns></returns> 742 /// <param name="agentID"></param>
753 protected internal List<ScenePresence> GetScenePresences() 743 /// <returns>null if the presence was not found</returns>
744 protected internal ScenePresence GetScenePresence(UUID agentID)
754 { 745 {
755 List<ScenePresence> result; 746 ScenePresence sp;
756 lock (m_scenePresences) 747 lock (m_scenePresences)
757 { 748 {
758 result = new List<ScenePresence>(m_scenePresenceArray.Length); 749 m_scenePresences.TryGetValue(agentID, out sp);
759 result.AddRange(m_scenePresenceArray);
760 } 750 }
761 return result; 751 return sp;
762 } 752 }
763 753
764 /// <summary> 754 /// <summary>
765 /// Request a filtered list of m_scenePresences in this World 755 /// Request the scene presence by name.
766 /// Returns a copy so it can be iterated without a lock.
767 /// There is no guarantee that presences will remain in the scene after the list is returned.
768 /// </summary> 756 /// </summary>
769 /// <returns></returns> 757 /// <param name="firstName"></param>
770 protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter) 758 /// <param name="lastName"></param>
759 /// <returns>null if the presence was not found</returns>
760 protected internal ScenePresence GetScenePresence(string firstName, string lastName)
771 { 761 {
772 List<ScenePresence> result = new List<ScenePresence>(); 762 foreach (ScenePresence presence in GetScenePresences())
773 // Check each ScenePresence against the filter
774 ForEachScenePresence(delegate(ScenePresence presence)
775 { 763 {
776 if (filter(presence)) 764 if (presence.Firstname == firstName && presence.Lastname == lastName)
777 result.Add(presence); 765 return presence;
778 }); 766 }
779 return result; 767 return null;
780 } 768 }
781 769
782 /// <summary> 770 /// <summary>
783 /// Request the ScenePresence in this region matching filter. 771 /// Request the scene presence by localID.
784 /// Only the first match is returned.
785 ///
786 /// </summary> 772 /// </summary>
787 /// <param name="filter"></param> 773 /// <param name="localID"></param>
788 /// <returns></returns> 774 /// <returns>null if the presence was not found</returns>
789 protected internal ScenePresence GetScenePresence(FilterAvatarList filter) 775 protected internal ScenePresence GetScenePresence(uint localID)
790 { 776 {
791 ScenePresence result = null; 777 foreach (ScenePresence presence in GetScenePresences())
792 // Get all of the ScenePresences 778 if (presence.LocalId == localID)
793 List<ScenePresence> presences = GetScenePresences(); 779 return presence;
794 foreach (ScenePresence presence in presences) 780 return null;
795 {
796 if (filter(presence))
797 {
798 result = presence;
799 break;
800 }
801 }
802 return result;
803 } 781 }
804 782
805 protected internal ScenePresence GetScenePresence(string firstName, string lastName) 783 protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar)
806 { 784 {
807 return GetScenePresence(delegate(ScenePresence presence) 785 lock (m_scenePresences)
808 { 786 {
809 return(presence.Firstname == firstName && presence.Lastname == lastName); 787 m_scenePresences.TryGetValue(agentID, out avatar);
810 }); 788 }
811 } 789 return (avatar != null);
812
813 /// <summary>
814 /// Request a scene presence by UUID
815 /// </summary>
816 /// <param name="agentID"></param>
817 /// <returns>null if the agent was not found</returns>
818 protected internal ScenePresence GetScenePresence(UUID agentID)
819 {
820 ScenePresence sp;
821 TryGetAvatar(agentID, out sp);
822 return sp;
823 } 790 }
824 791
825 /// <summary> 792 protected internal bool TryGetAvatarByName(string name, out ScenePresence avatar)
826 /// Request the ScenePresence in this region by localID.
827 /// </summary>
828 /// <param name="localID"></param>
829 /// <returns></returns>
830 protected internal ScenePresence GetScenePresence(uint localID)
831 { 793 {
832 return GetScenePresence(delegate(ScenePresence presence) 794 avatar = null;
795 foreach (ScenePresence presence in GetScenePresences())
833 { 796 {
834 return (presence.LocalId == localID); 797 if (String.Compare(name, presence.ControllingClient.Name, true) == 0)
835 }); 798 {
799 avatar = presence;
800 break;
801 }
802 }
803 return (avatar != null);
836 } 804 }
837 805
838 /// <summary> 806 /// <summary>
@@ -986,24 +954,6 @@ namespace OpenSim.Region.Framework.Scenes
986 return group.GetChildPart(fullID); 954 return group.GetChildPart(fullID);
987 } 955 }
988 956
989 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
990 {
991 lock (m_scenePresences)
992 {
993 m_scenePresences.TryGetValue(avatarId, out avatar);
994 }
995 return (avatar != null);
996 }
997
998 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
999 {
1000 avatar = GetScenePresence(delegate(ScenePresence presence)
1001 {
1002 return (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0);
1003 });
1004 return (avatar != null);
1005 }
1006
1007 /// <summary> 957 /// <summary>
1008 /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over 958 /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over
1009 /// it 959 /// it
@@ -1066,6 +1016,10 @@ namespace OpenSim.Region.Framework.Scenes
1066 return UUID.Zero; 1016 return UUID.Zero;
1067 } 1017 }
1068 1018
1019 /// <summary>
1020 /// Performs action on all scene object groups.
1021 /// </summary>
1022 /// <param name="action"></param>
1069 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1023 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1070 { 1024 {
1071 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); 1025 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
@@ -1085,23 +1039,41 @@ namespace OpenSim.Region.Framework.Scenes
1085 1039
1086 1040
1087 /// <summary> 1041 /// <summary>
1088 /// Performs action on all scene presences. 1042 /// Performs action on all scene presences. This can ultimately run the actions in parallel but
1043 /// any delegates passed in will need to implement their own locking on data they reference and
1044 /// modify outside of the scope of the delegate.
1089 /// </summary> 1045 /// </summary>
1090 /// <param name="action"></param> 1046 /// <param name="action"></param>
1091 public void ForEachScenePresence(Action<ScenePresence> action) 1047 public void ForEachScenePresence(Action<ScenePresence> action)
1092 { 1048 {
1093 List<ScenePresence> presences = GetScenePresences(); 1049 // Once all callers have their delegates configured for parallelism, we can unleash this
1094 try 1050 /*
1051 Action<ScenePresence> protectedAction = new Action<ScenePresence>(delegate(ScenePresence sp)
1052 {
1053 try
1054 {
1055 action(sp);
1056 }
1057 catch (Exception e)
1058 {
1059 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1060 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
1061 }
1062 });
1063 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
1064 */
1065 // For now, perform actiona serially
1066 foreach (ScenePresence sp in GetScenePresences())
1095 { 1067 {
1096 foreach(ScenePresence presence in presences) 1068 try
1097 { 1069 {
1098 action(presence); 1070 action(sp);
1071 }
1072 catch (Exception e)
1073 {
1074 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1075 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
1099 } 1076 }
1100 }
1101 catch (Exception e)
1102 {
1103 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1104 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
1105 } 1077 }
1106 } 1078 }
1107 1079
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index a955532..3b84734 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -454,8 +454,10 @@ namespace OpenSim.Region.Framework.Scenes
454 454
455 ForEachCurrentScene(delegate(Scene scene) 455 ForEachCurrentScene(delegate(Scene scene)
456 { 456 {
457 List<ScenePresence> scenePresences = scene.GetScenePresences(); 457 scene.ForEachScenePresence(delegate(ScenePresence sp)
458 presences.AddRange(scenePresences); 458 {
459 presences.Add(sp);
460 });
459 }); 461 });
460 462
461 return presences; 463 return presences;
@@ -484,11 +486,11 @@ namespace OpenSim.Region.Framework.Scenes
484 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); 486 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
485 } 487 }
486 488
487 public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 489 public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
488 { 490 {
489 foreach (Scene scene in m_localScenes) 491 foreach (Scene scene in m_localScenes)
490 { 492 {
491 if (scene.TryGetAvatar(avatarId, out avatar)) 493 if (scene.TryGetScenePresence(avatarId, out avatar))
492 { 494 {
493 return true; 495 return true;
494 } 496 }
@@ -503,7 +505,7 @@ namespace OpenSim.Region.Framework.Scenes
503 ScenePresence avatar = null; 505 ScenePresence avatar = null;
504 foreach (Scene mScene in m_localScenes) 506 foreach (Scene mScene in m_localScenes)
505 { 507 {
506 if (mScene.TryGetAvatar(avatarId, out avatar)) 508 if (mScene.TryGetScenePresence(avatarId, out avatar))
507 { 509 {
508 scene = mScene; 510 scene = mScene;
509 return true; 511 return true;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 539f2b1..4b2641c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -682,7 +682,7 @@ namespace OpenSim.Region.Framework.Scenes
682 if (m_parentGroup != null) // TODO can there be a SOP without a SOG? 682 if (m_parentGroup != null) // TODO can there be a SOP without a SOG?
683 { 683 {
684 ScenePresence avatar; 684 ScenePresence avatar;
685 if (m_parentGroup.Scene.TryGetAvatar(m_sitTargetAvatar, out avatar)) 685 if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar))
686 { 686 {
687 avatar.ParentPosition = GetWorldPosition(); 687 avatar.ParentPosition = GetWorldPosition();
688 } 688 }
@@ -1332,11 +1332,11 @@ namespace OpenSim.Region.Framework.Scenes
1332 if (volume < 0) 1332 if (volume < 0)
1333 volume = 0; 1333 volume = 0;
1334 1334
1335 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 1335 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
1336 foreach (ScenePresence p in avatarts)
1337 { 1336 {
1338 p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); 1337 if(!sp.IsChildAgent)
1339 } 1338 sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume);
1339 });
1340 } 1340 }
1341 1341
1342 /// <summary> 1342 /// <summary>
@@ -2626,12 +2626,13 @@ namespace OpenSim.Region.Framework.Scenes
2626 TaskInventory.LockItemsForRead(false); 2626 TaskInventory.LockItemsForRead(false);
2627 } 2627 }
2628 2628
2629 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2629 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
2630 foreach (ScenePresence p in avatarts)
2631 { 2630 {
2632 if (!(Util.GetDistanceTo(p.AbsolutePosition, AbsolutePosition) >= 100)) 2631 if (sp.IsChildAgent)
2633 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 2632 return;
2634 } 2633 if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100))
2634 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2635 });
2635 } 2636 }
2636 2637
2637 public void RemFlag(PrimFlags flag) 2638 public void RemFlag(PrimFlags flag)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1e530e1..5c54616 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2598,35 +2598,33 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2598 2598
2599 List<Vector3> CoarseLocations = new List<Vector3>(); 2599 List<Vector3> CoarseLocations = new List<Vector3>();
2600 List<UUID> AvatarUUIDs = new List<UUID>(); 2600 List<UUID> AvatarUUIDs = new List<UUID>();
2601 List<ScenePresence> avatars = m_scene.GetAvatars(); 2601 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2602 for (int i = 0; i < avatars.Count; i++)
2603 { 2602 {
2604 // Requested by LibOMV. Send Course Location on self. 2603 if (sp.IsChildAgent)
2605 //if (avatars[i] != this) 2604 return;
2606 //{ 2605
2607 if (avatars[i].ParentID != 0) 2606 if (sp.ParentID != 0)
2607 {
2608 // sitting avatar
2609 SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID);
2610 if (sop != null)
2608 { 2611 {
2609 // sitting avatar 2612 CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos);
2610 SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); 2613 AvatarUUIDs.Add(sp.UUID);
2611 if (sop != null)
2612 {
2613 CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos);
2614 AvatarUUIDs.Add(avatars[i].UUID);
2615 }
2616 else
2617 {
2618 // we can't find the parent.. ! arg!
2619 CoarseLocations.Add(avatars[i].m_pos);
2620 AvatarUUIDs.Add(avatars[i].UUID);
2621 }
2622 } 2614 }
2623 else 2615 else
2624 { 2616 {
2625 CoarseLocations.Add(avatars[i].m_pos); 2617 // we can't find the parent.. ! arg!
2626 AvatarUUIDs.Add(avatars[i].UUID); 2618 CoarseLocations.Add(sp.m_pos);
2619 AvatarUUIDs.Add(sp.UUID);
2627 } 2620 }
2628 //} 2621 }
2629 } 2622 else
2623 {
2624 CoarseLocations.Add(sp.m_pos);
2625 AvatarUUIDs.Add(sp.UUID);
2626 }
2627 });
2630 2628
2631 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2629 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2632 2630
@@ -2700,13 +2698,15 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2700 m_perfMonMS = Util.EnvironmentTickCount(); 2698 m_perfMonMS = Util.EnvironmentTickCount();
2701 2699
2702 // only send update from root agents to other clients; children are only "listening posts" 2700 // only send update from root agents to other clients; children are only "listening posts"
2703 List<ScenePresence> avatars = m_scene.GetAvatars(); 2701 int count = 0;
2704 foreach (ScenePresence avatar in avatars) 2702 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2705 { 2703 {
2706 SendFullUpdateToOtherClient(avatar); 2704 if (sp.IsChildAgent)
2707 2705 return;
2708 } 2706 SendFullUpdateToOtherClient(sp);
2709 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2707 ++count;
2708 });
2709 m_scene.StatsReporter.AddAgentUpdates(count);
2710 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2710 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2711 2711
2712 Animator.SendAnimPack(); 2712 Animator.SendAnimPack();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index 840039c..dd9f8f6 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
66 throw new NotImplementedException(); 66 throw new NotImplementedException();
67 } 67 }
68 68
69 public override bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence) 69 public override bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence)
70 { 70 {
71 throw new NotImplementedException(); 71 throw new NotImplementedException();
72 } 72 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index c864993..2fcc477 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -318,9 +318,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
318 { 318 {
319 Scene scene = client.Scene as Scene; 319 Scene scene = client.Scene as Scene;
320 m_log.DebugFormat("[Concierge]: {0} logs off from {1}", client.Name, scene.RegionInfo.RegionName); 320 m_log.DebugFormat("[Concierge]: {0} logs off from {1}", client.Name, scene.RegionInfo.RegionName);
321 List<ScenePresence> avs = scene.GetAvatars(); 321 AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
322 AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, avs.Count)); 322 UpdateBroker(scene);
323 UpdateBroker(scene, avs);
324 } 323 }
325 } 324 }
326 325
@@ -331,11 +330,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
331 { 330 {
332 Scene scene = agent.Scene; 331 Scene scene = agent.Scene;
333 m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName); 332 m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName);
334 List<ScenePresence> avs = scene.GetAvatars();
335 WelcomeAvatar(agent, scene); 333 WelcomeAvatar(agent, scene);
336 AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name, 334 AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name,
337 scene.RegionInfo.RegionName, avs.Count)); 335 scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
338 UpdateBroker(scene, avs); 336 UpdateBroker(scene);
339 } 337 }
340 } 338 }
341 339
@@ -346,10 +344,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
346 { 344 {
347 Scene scene = agent.Scene; 345 Scene scene = agent.Scene;
348 m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName); 346 m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName);
349 List<ScenePresence> avs = scene.GetAvatars();
350 AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name, 347 AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name,
351 scene.RegionInfo.RegionName, avs.Count)); 348 scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
352 UpdateBroker(scene, avs); 349 UpdateBroker(scene);
353 } 350 }
354 } 351 }
355 352
@@ -368,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
368 } 365 }
369 } 366 }
370 367
371 protected void UpdateBroker(IScene scene, List<ScenePresence> avatars) 368 protected void UpdateBroker(Scene scene)
372 { 369 {
373 if (String.IsNullOrEmpty(m_brokerURI)) 370 if (String.IsNullOrEmpty(m_brokerURI))
374 return; 371 return;
@@ -377,24 +374,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
377 374
378 // create XML sniplet 375 // create XML sniplet
379 StringBuilder list = new StringBuilder(); 376 StringBuilder list = new StringBuilder();
380 if (0 == avatars.Count) 377 list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n",
381 { 378 scene.GetRootAgentCount(), scene.RegionInfo.RegionName,
382 list.Append(String.Format("<avatars count=\"0\" region_name=\"{0}\" region_uuid=\"{1}\" timestamp=\"{2}\" />", 379 scene.RegionInfo.RegionID,
383 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
384 DateTime.UtcNow.ToString("s"))); 380 DateTime.UtcNow.ToString("s")));
385 } 381 scene.ForEachScenePresence(delegate(ScenePresence sp)
386 else
387 { 382 {
388 list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n", 383 if (!sp.IsChildAgent)
389 avatars.Count, scene.RegionInfo.RegionName,
390 scene.RegionInfo.RegionID,
391 DateTime.UtcNow.ToString("s")));
392 foreach (ScenePresence av in avatars)
393 { 384 {
394 list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", av.Name, av.UUID)); 385 list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
386 list.Append("</avatars>");
395 } 387 }
396 list.Append("</avatars>"); 388 });
397 }
398 string payload = list.ToString(); 389 string payload = list.ToString();
399 390
400 // post via REST to broker 391 // post via REST to broker
@@ -529,7 +520,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
529 // protected void AnnounceToAgentsRegion(Scene scene, string msg) 520 // protected void AnnounceToAgentsRegion(Scene scene, string msg)
530 // { 521 // {
531 // ScenePresence agent = null; 522 // ScenePresence agent = null;
532 // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetAvatar(client.AgentId, out agent)) 523 // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent))
533 // AnnounceToAgentsRegion(agent, msg); 524 // AnnounceToAgentsRegion(agent, msg);
534 // else 525 // else
535 // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name); 526 // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 68e6497..61c51e0 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -328,17 +328,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
328 } 328 }
329 */ 329 */
330 330
331
332 void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) 331 void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
333 { 332 {
334 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) 333 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
335 { 334 {
336 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); 335 if (m_debugEnabled)
336 m_log.DebugFormat(
337 "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
338 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
337 339
338 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 340 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
339 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); 341 remoteClient.SendDirGroupsReply(
340 } 342 queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray());
341 343 }
342 } 344 }
343 345
344 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) 346 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
@@ -363,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
363 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 365 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
364 } 366 }
365 367
366 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient) 368 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
367 { 369 {
368 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 370 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
369 371
@@ -593,6 +595,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
593 return m_groupData.GetGroupRecord(null, GroupID, null); 595 return m_groupData.GetGroupRecord(null, GroupID, null);
594 } 596 }
595 597
598 public GroupRecord GetGroupRecord(string name)
599 {
600 return m_groupData.GetGroupRecord(null, UUID.Zero, name);
601 }
602
596 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 603 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
597 { 604 {
598 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 605 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -652,7 +659,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
652 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); 659 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID);
653 660
654 return data; 661 return data;
655
656 } 662 }
657 663
658 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) 664 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID)
@@ -662,8 +668,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
662 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); 668 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID);
663 669
664 return data; 670 return data;
665
666
667 } 671 }
668 672
669 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) 673 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID)
@@ -712,7 +716,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
712 716
713 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 717 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
714 { 718 {
715 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 719 if (m_debugEnabled)
720 m_log.DebugFormat(
721 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
722 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
716 723
717 return m_groupData.GetAgentGroupMembership(null, agentID, groupID); 724 return m_groupData.GetAgentGroupMembership(null, agentID, groupID);
718 } 725 }
@@ -746,7 +753,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
746 return UUID.Zero; 753 return UUID.Zero;
747 } 754 }
748 // is there is a money module present ? 755 // is there is a money module present ?
749 IMoneyModule money=remoteClient.Scene.RequestModuleInterface<IMoneyModule>(); 756 IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
750 if (money != null) 757 if (money != null)
751 { 758 {
752 // do the transaction, that is if the agent has got sufficient funds 759 // do the transaction, that is if the agent has got sufficient funds
@@ -1166,8 +1173,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1166 else 1173 else
1167 { 1174 {
1168 string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; 1175 string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1169 if (account.ServiceURLs["HomeURI"] != null) 1176 object homeUriObj;
1170 domain = account.ServiceURLs["HomeURI"].ToString(); 1177 if (account.ServiceURLs.TryGetValue("HomeURI", out homeUriObj) && homeUriObj != null)
1178 domain = homeUriObj.ToString();
1171 // They're a local user, use this: 1179 // They're a local user, use this:
1172 info.RequestID.UserServiceURL = domain; 1180 info.RequestID.UserServiceURL = domain;
1173 } 1181 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 9e0fa2d..621ab28 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -55,7 +55,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
55 GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); 55 GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID);
56 void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); 56 void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID);
57 57
58
59 void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 58 void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
60 void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 59 void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
61 List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID); 60 List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 964d0bb..24ae4f7 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -47,9 +47,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
48 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector 48 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
49 { 49 {
50 private static readonly ILog m_log = 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 51
54 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | 52 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
55 GroupPowers.Accountable | 53 GroupPowers.Accountable |
@@ -354,11 +352,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
354 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; 352 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
355 353
356 return MemberGroupProfile; 354 return MemberGroupProfile;
357
358 } 355 }
359 356
360
361
362 public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) 357 public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
363 { 358 {
364 Hashtable param = new Hashtable(); 359 Hashtable param = new Hashtable();
@@ -470,7 +465,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
470 XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param); 465 XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param);
471 } 466 }
472 467
473
474 public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search) 468 public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
475 { 469 {
476 Hashtable param = new Hashtable(); 470 Hashtable param = new Hashtable();
@@ -531,7 +525,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
531 return HashTableToGroupMembershipData(respData); 525 return HashTableToGroupMembershipData(respData);
532 } 526 }
533 527
534
535 public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID) 528 public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
536 { 529 {
537 Hashtable param = new Hashtable(); 530 Hashtable param = new Hashtable();
@@ -778,7 +771,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
778 771
779 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) 772 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
780 { 773 {
781
782 GroupRecord group = new GroupRecord(); 774 GroupRecord group = new GroupRecord();
783 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); 775 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
784 group.GroupName = groupProfile["Name"].ToString(); 776 group.GroupName = groupProfile["Name"].ToString();
@@ -797,6 +789,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
797 789
798 return group; 790 return group;
799 } 791 }
792
800 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) 793 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
801 { 794 {
802 GroupMembershipData data = new GroupMembershipData(); 795 GroupMembershipData data = new GroupMembershipData();
@@ -829,6 +822,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
829 data.MembershipFee = int.Parse((string)respData["MembershipFee"]); 822 data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
830 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); 823 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
831 data.ShowInList = ((string)respData["ShowInList"] == "1"); 824 data.ShowInList = ((string)respData["ShowInList"] == "1");
825
832 return data; 826 return data;
833 } 827 }
834 828
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 6e742f1..ab0be77 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
110 if (m_avatars.ContainsKey(agentID)) 110 if (m_avatars.ContainsKey(agentID))
111 { 111 {
112 ScenePresence sp; 112 ScenePresence sp;
113 scene.TryGetAvatar(agentID, out sp); 113 scene.TryGetScenePresence(agentID, out sp);
114 sp.DoAutoPilot(0, pos, m_avatars[agentID]); 114 sp.DoAutoPilot(0, pos, m_avatars[agentID]);
115 } 115 }
116 } 116 }
@@ -165,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
165 p_scene.AddNewClient(npcAvatar); 165 p_scene.AddNewClient(npcAvatar);
166 166
167 ScenePresence sp; 167 ScenePresence sp;
168 if (p_scene.TryGetAvatar(npcAvatar.AgentId, out sp)) 168 if (p_scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
169 { 169 {
170 AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene); 170 AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene);
171 171
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
index 0b8771c..b42d3bf 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
@@ -625,36 +625,37 @@ namespace OpenSim.Region.RegionCombinerModule
625 return; 625 return;
626 } 626 }
627 627
628 List<ScenePresence> avatars = connectiondata.RegionScene.GetAvatars();
629 List<Vector3> CoarseLocations = new List<Vector3>(); 628 List<Vector3> CoarseLocations = new List<Vector3>();
630 List<UUID> AvatarUUIDs = new List<UUID>(); 629 List<UUID> AvatarUUIDs = new List<UUID>();
631 for (int i = 0; i < avatars.Count; i++) 630 connectiondata.RegionScene.ForEachScenePresence(delegate(ScenePresence sp)
632 { 631 {
633 if (avatars[i].UUID != presence.UUID) 632 if (sp.IsChildAgent)
633 return;
634 if (sp.UUID != presence.UUID)
634 { 635 {
635 if (avatars[i].ParentID != 0) 636 if (sp.ParentID != 0)
636 { 637 {
637 // sitting avatar 638 // sitting avatar
638 SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(avatars[i].ParentID); 639 SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(sp.ParentID);
639 if (sop != null) 640 if (sop != null)
640 { 641 {
641 CoarseLocations.Add(sop.AbsolutePosition + avatars[i].AbsolutePosition); 642 CoarseLocations.Add(sop.AbsolutePosition + sp.AbsolutePosition);
642 AvatarUUIDs.Add(avatars[i].UUID); 643 AvatarUUIDs.Add(sp.UUID);
643 } 644 }
644 else 645 else
645 { 646 {
646 // we can't find the parent.. ! arg! 647 // we can't find the parent.. ! arg!
647 CoarseLocations.Add(avatars[i].AbsolutePosition); 648 CoarseLocations.Add(sp.AbsolutePosition);
648 AvatarUUIDs.Add(avatars[i].UUID); 649 AvatarUUIDs.Add(sp.UUID);
649 } 650 }
650 } 651 }
651 else 652 else
652 { 653 {
653 CoarseLocations.Add(avatars[i].AbsolutePosition); 654 CoarseLocations.Add(sp.AbsolutePosition);
654 AvatarUUIDs.Add(avatars[i].UUID); 655 AvatarUUIDs.Add(sp.UUID);
655 } 656 }
656 } 657 }
657 } 658 });
658 DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); 659 DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence);
659 } 660 }
660 661
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0c373b9..3f630f4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5293,7 +5293,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5293 public LSL_Integer llGetRegionAgentCount() 5293 public LSL_Integer llGetRegionAgentCount()
5294 { 5294 {
5295 m_host.AddScriptLPS(1); 5295 m_host.AddScriptLPS(1);
5296 return new LSL_Integer(World.GetAvatars().Count); 5296 return new LSL_Integer(World.GetRootAgentCount());
5297 } 5297 }
5298 5298
5299 public LSL_Vector llGetRegionCorner() 5299 public LSL_Vector llGetRegionCorner()
@@ -9096,17 +9096,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9096 landObject.SetMediaUrl(url); 9096 landObject.SetMediaUrl(url);
9097 9097
9098 // now send to all (non-child) agents 9098 // now send to all (non-child) agents
9099 List<ScenePresence> agents = World.GetAvatars(); 9099 World.ForEachScenePresence(delegate(ScenePresence sp)
9100 foreach (ScenePresence agent in agents)
9101 { 9100 {
9102 agent.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, 9101 if (!sp.IsChildAgent)
9103 landData.MediaID, 9102 {
9104 landData.MediaAutoScale, 9103 sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL,
9105 mediaType, 9104 landData.MediaID,
9106 description, 9105 landData.MediaAutoScale,
9107 width, height, 9106 mediaType,
9108 loop); 9107 description,
9109 } 9108 width, height,
9109 loop);
9110 }
9111 });
9110 } 9112 }
9111 else if (!presence.IsChildAgent) 9113 else if (!presence.IsChildAgent)
9112 { 9114 {
@@ -9127,13 +9129,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9127 if (presence == null) 9129 if (presence == null)
9128 { 9130 {
9129 // send to all (non-child) agents 9131 // send to all (non-child) agents
9130 List<ScenePresence> agents = World.GetAvatars(); 9132 World.ForEachScenePresence(delegate(ScenePresence sp)
9131 foreach (ScenePresence agent in agents)
9132 { 9133 {
9133 agent.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? 9134 if (!sp.IsChildAgent)
9134 (ParcelMediaCommandEnum)commandToSend, 9135 {
9135 time); 9136 sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
9136 } 9137 (ParcelMediaCommandEnum)commandToSend,
9138 time);
9139 }
9140 });
9137 } 9141 }
9138 else if (!presence.IsChildAgent) 9142 else if (!presence.IsChildAgent)
9139 { 9143 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 845834e..9474bab 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -697,10 +697,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
697 CheckThreatLevel(ThreatLevel.None, "osGetAgents"); 697 CheckThreatLevel(ThreatLevel.None, "osGetAgents");
698 698
699 LSL_List result = new LSL_List(); 699 LSL_List result = new LSL_List();
700 foreach (ScenePresence avatar in World.GetAvatars()) 700 World.ForEachScenePresence(delegate(ScenePresence sp)
701 { 701 {
702 result.Add(avatar.Name); 702 if (!sp.IsChildAgent)
703 } 703 result.Add(sp.Name);
704 });
704 return result; 705 return result;
705 } 706 }
706 707
@@ -1989,19 +1990,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1989 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); 1990 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
1990 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 1991 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
1991 { 1992 {
1992 foreach (ScenePresence presence in World.GetAvatars()) 1993 World.ForEachScenePresence(delegate(ScenePresence sp)
1993 { 1994 {
1994 if ((presence.Firstname == FirstName) && 1995 if (!sp.IsChildAgent &&
1995 presence.Lastname == SurName) 1996 sp.Firstname == FirstName &&
1997 sp.Lastname == SurName)
1996 { 1998 {
1997 // kick client... 1999 // kick client...
1998 if (alert != null) 2000 if (alert != null)
1999 presence.ControllingClient.Kick(alert); 2001 sp.ControllingClient.Kick(alert);
2000 2002
2001 // ...and close on our side 2003 // ...and close on our side
2002 presence.Scene.IncomingCloseAgent(presence.UUID); 2004 sp.Scene.IncomingCloseAgent(sp.UUID);
2003 } 2005 }
2004 } 2006 });
2005 } 2007 }
2006 } 2008 }
2007 2009
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 829fbb7..2296379 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -404,70 +404,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
404 404
405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
406 { 406 {
407 List<ScenePresence> presences;
408 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 407 List<SensedEntity> sensedEntities = new List<SensedEntity>();
409 408
410 // If this is an avatar sense by key try to get them directly
411 // rather than getting a list to scan through
412 if (ts.keyID != UUID.Zero)
413 {
414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID);
415 if (p == null)
416 return sensedEntities;
417 presences = new List<ScenePresence>();
418 presences.Add(p);
419 }
420 else
421 {
422 presences = new List<ScenePresence>(m_CmdManager.m_ScriptEngine.World.GetScenePresences());
423 }
424
425 // If nobody about quit fast 409 // If nobody about quit fast
426 if (presences.Count == 0) 410 if(m_CmdManager.m_ScriptEngine.World.GetRootAgentCount() == 0)
427 return sensedEntities; 411 return sensedEntities;
428 412
429 SceneObjectPart SensePoint = ts.host; 413 SceneObjectPart SensePoint = ts.host;
430
431 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 414 Vector3 fromRegionPos = SensePoint.AbsolutePosition;
432
433 Quaternion q = SensePoint.RotationOffset; 415 Quaternion q = SensePoint.RotationOffset;
434 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 416 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
435 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 417 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
436 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 418 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
437
438 bool attached = (SensePoint.AttachmentPoint != 0); 419 bool attached = (SensePoint.AttachmentPoint != 0);
439 bool nameSearch = (ts.name != null && ts.name != "");
440 Vector3 toRegionPos; 420 Vector3 toRegionPos;
441 double dis; 421 double dis;
442 422
443 for (int i = 0; i < presences.Count; i++) 423 Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence)
444 { 424 {
445 ScenePresence presence = presences[i]; 425 if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0)
446 bool keep = true; 426 return;
427
428 // if the object the script is in is attached and the avatar is the owner
429 // then this one is not wanted
430 if (attached && presence.UUID == SensePoint.OwnerID)
431 return;
447 432
448 if (presence.IsDeleted)
449 continue;
450
451 if (presence.IsChildAgent)
452 keep = false;
453 toRegionPos = presence.AbsolutePosition; 433 toRegionPos = presence.AbsolutePosition;
454
455 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); 434 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos));
456 435
457 // are they in range 436 // are they in range
458 if (keep && dis <= ts.range) 437 if (dis <= ts.range)
459 { 438 {
460 // if the object the script is in is attached and the avatar is the owner
461 // then this one is not wanted
462 if (attached && presence.UUID == SensePoint.OwnerID)
463 keep = false;
464
465 // check the name if needed
466 if (keep && nameSearch && ts.name != presence.Name)
467 keep = false;
468
469 // Are they in the required angle of view 439 // Are they in the required angle of view
470 if (keep && ts.arc < Math.PI) 440 if (ts.arc < Math.PI)
471 { 441 {
472 // not omni-directional. Can you see it ? 442 // not omni-directional. Can you see it ?
473 // vec forward_dir = llRot2Fwd(llGetRot()) 443 // vec forward_dir = llRot2Fwd(llGetRot())
@@ -488,26 +458,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
488 catch 458 catch
489 { 459 {
490 } 460 }
491 if (ang_obj > ts.arc) keep = false; 461 if (ang_obj <= ts.arc)
462 {
463 sensedEntities.Add(new SensedEntity(dis, presence.UUID));
464 }
492 } 465 }
493 } 466 }
494 else 467 });
495 {
496 keep = false;
497 }
498 468
499 // Do not report gods, not even minor ones 469 // If this is an avatar sense by key try to get them directly
500 if (keep && presence.GodLevel > 0.0) 470 // rather than getting a list to scan through
501 keep = false; 471 if (ts.keyID != UUID.Zero)
502 472 {
503 if (keep) // add to list with distance 473 ScenePresence sp;
504 { 474 // Try direct lookup by UUID
505 sensedEntities.Add(new SensedEntity(dis, presence.UUID)); 475 if(!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out sp))
506 }
507
508 // If this is a search by name and we have just found it then no more to do
509 if (nameSearch && ts.name == presence.Name)
510 return sensedEntities; 476 return sensedEntities;
477 senseEntity(sp);
478 }
479 else if (ts.name != null && ts.name != "")
480 {
481 ScenePresence sp;
482 // Try lookup by name will return if/when found
483 if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
484 return sensedEntities;
485 senseEntity(sp);
486 }
487 else
488 {
489 m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity);
511 } 490 }
512 return sensedEntities; 491 return sensedEntities;
513 } 492 }
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
index a567413..dcbd717 100644
--- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
+++ b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
@@ -68,17 +68,15 @@ namespace OpenSim.Region.UserStatistics
68 HTMLUtil.OL_O(ref output, ""); 68 HTMLUtil.OL_O(ref output, "");
69 foreach (Scene scene in all_scenes) 69 foreach (Scene scene in all_scenes)
70 { 70 {
71 List<ScenePresence> avatarInScene = scene.GetScenePresences();
72
73 HTMLUtil.LI_O(ref output, String.Empty); 71 HTMLUtil.LI_O(ref output, String.Empty);
74 output.Append(scene.RegionInfo.RegionName); 72 output.Append(scene.RegionInfo.RegionName);
75 HTMLUtil.OL_O(ref output, String.Empty); 73 HTMLUtil.OL_O(ref output, String.Empty);
76 foreach (ScenePresence av in avatarInScene) 74 scene.ForEachScenePresence(delegate(ScenePresence av)
77 { 75 {
78 Dictionary<string,string> queues = new Dictionary<string, string>(); 76 Dictionary<string, string> queues = new Dictionary<string, string>();
79 if (av.ControllingClient is IStatsCollector) 77 if (av.ControllingClient is IStatsCollector)
80 { 78 {
81 IStatsCollector isClient = (IStatsCollector) av.ControllingClient; 79 IStatsCollector isClient = (IStatsCollector)av.ControllingClient;
82 queues = decodeQueueReport(isClient.Report()); 80 queues = decodeQueueReport(isClient.Report());
83 } 81 }
84 HTMLUtil.LI_O(ref output, String.Empty); 82 HTMLUtil.LI_O(ref output, String.Empty);
@@ -92,8 +90,8 @@ namespace OpenSim.Region.UserStatistics
92 else 90 else
93 { 91 {
94 output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X, 92 output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X,
95 (int) av.AbsolutePosition.Y, 93 (int)av.AbsolutePosition.Y,
96 (int) av.AbsolutePosition.Z)); 94 (int)av.AbsolutePosition.Z));
97 } 95 }
98 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1)); 96 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
99 97
@@ -124,7 +122,7 @@ namespace OpenSim.Region.UserStatistics
124 122
125 HTMLUtil.UL_C(ref output); 123 HTMLUtil.UL_C(ref output);
126 HTMLUtil.LI_C(ref output); 124 HTMLUtil.LI_C(ref output);
127 } 125 });
128 HTMLUtil.OL_C(ref output); 126 HTMLUtil.OL_C(ref output);
129 } 127 }
130 HTMLUtil.OL_C(ref output); 128 HTMLUtil.OL_C(ref output);