From 820242bc49d9a0ed558a72fda2f7bbb85b716b5f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 27 Oct 2011 02:05:59 +0100 Subject: [PATCH 1/7] Fix a bug I introduced yesterday in ODE physics where prim scripts would only receive the very first collision. --- .../Framework/Scenes/SceneObjectPart.cs | 2 ++ .../Region/Physics/Manager/PhysicsActor.cs | 2 ++ OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 23 ++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8b6810251c..c8ecc9bf90 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2082,6 +2082,8 @@ namespace OpenSim.Region.Framework.Scenes public void PhysicsCollision(EventArgs e) { +// m_log.DebugFormat("Invoking PhysicsCollision on {0} {1} {2}", Name, LocalId, UUID); + // single threaded here CollisionEventUpdate a = (CollisionEventUpdate)e; diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 362f997e18..49f60f8d5e 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -76,6 +76,8 @@ namespace OpenSim.Region.Physics.Manager /// public int Count { get { return m_objCollisionList.Count; } } + public bool CollisionsOnPreviousFrame { get; private set; } + public Dictionary m_objCollisionList; public CollisionEventUpdate(Dictionary objCollisionList) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 036388538c..ea6af3a1be 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -193,6 +193,15 @@ namespace OpenSim.Region.Physics.OdePlugin private int m_eventsubscription; private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); + /// + /// Signal whether there were collisions on the previous frame, so we know if we need to send the + /// empty CollisionEventsThisFrame to the prim so that it can detect the end of a collision. + /// + /// + /// This is probably a temporary measure, pending storing this information consistently in CollisionEventUpdate itself. + /// + private bool m_collisionsOnPreviousFrame; + private IntPtr m_linkJoint = IntPtr.Zero; internal volatile bool childPrim; @@ -3025,8 +3034,20 @@ Console.WriteLine(" JointCreateFixed"); public void SendCollisions() { - if (CollisionEventsThisFrame.Count > 0) + if (m_collisionsOnPreviousFrame || CollisionEventsThisFrame.Count > 0) + { base.SendCollisionUpdate(CollisionEventsThisFrame); + + if (CollisionEventsThisFrame.Count > 0) + { + m_collisionsOnPreviousFrame = true; + CollisionEventsThisFrame.Clear(); + } + else + { + m_collisionsOnPreviousFrame = false; + } + } } public override bool SubscribedEvents() From e210d958219d0c400544f849202279c78feeea9d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 27 Oct 2011 02:50:58 +0100 Subject: [PATCH 2/7] Don't blow our brains out if LLClientView.BulkInventoryUpdate() is wrongly passed a null node reference. Addresses worst aspect of http://opensimulator.org/mantis/view.php?id=5752 --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7affa454c6..9f24ee7de9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -1958,8 +1958,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP SendBulkUpdateInventoryItem((InventoryItemBase)node); else if (node is InventoryFolderBase) SendBulkUpdateInventoryFolder((InventoryFolderBase)node); + else if (node != null) + m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name); else - m_log.ErrorFormat("[CLIENT]: Client for {0} sent unknown inventory node named {1}", Name, node.Name); + m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name); } protected void SendBulkUpdateInventoryItem(InventoryItemBase item) From 76c50d23f2920e391358d5c98cba11d11021cbb8 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 27 Oct 2011 02:56:08 +0100 Subject: [PATCH 3/7] Comment out inventory folder bulk update code on InventoryAccepted message introduced in commit db91044 on Aug 22 2011 This should be unecessary since the folder update is already made at the time of the offer (and moved to trash if not accepted). This code was also not taking into account the situation where an item was accepted. Needs more fixing if this results in an aggression elsewhere. --- .../Transfer/InventoryTransferModule.cs | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index f46d9f74d2..19c774f7c6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -275,19 +275,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { if (m_TransferModule != null) m_TransferModule.SendInstantMessage(im, delegate(bool success) { - // Send BulkUpdateInventory - IInventoryService invService = scene.InventoryService; - UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip - InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); - folder = invService.GetFolder(folder); + // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 + // and is apparently supposed to fix bulk inventory updates after accepting items. But + // instead it appears to cause two copies of an accepted folder for the receiving user in + // at least some cases. Folder/item update is already done when the offer is made (see code above) - ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); - - // If the user has left the scene by the time the message comes back then we can't send - // them the update. - if (fromUser != null) - fromUser.ControllingClient.SendBulkUpdateInventory(folder); +// // Send BulkUpdateInventory +// IInventoryService invService = scene.InventoryService; +// UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip +// +// InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); +// folder = invService.GetFolder(folder); +// +// ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); +// +// // If the user has left the scene by the time the message comes back then we can't send +// // them the update. +// if (fromUser != null) +// fromUser.ControllingClient.SendBulkUpdateInventory(folder); }); } } From 40bee97015362bd716193081113cc0940b4d7cb2 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 27 Oct 2011 03:01:27 +0100 Subject: [PATCH 4/7] For now, comment out error message on new script engine console commands. This causes false positives if a simulator has more than 1 region and the current region is 'root' since this sends the command separately to each region and each region has its own XEngine --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 240e36fd8c..1c16c8736f 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -374,7 +374,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine IScriptInstance instance = GetInstance(itemId); if (instance == null) { - MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId); + // Commented out for now since this will cause false reports on simulators with more than + // one scene where the current command line set region is 'root' (which causes commands to + // go to both regions... (sigh) +// MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId); return; } else From b98613091cd6dc2f914fb5ab38ca33cdff21fc24 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 00:42:21 -0700 Subject: [PATCH 5/7] Added new ForEachRootScenePresence to Scene since almost every delegate passed to ForEachScenePresence checks for !IsChildAgent first. It consolidates child and root handling for coming refactors. --- .../CoreModules/Avatar/Chat/ChatModule.cs | 7 +-- .../CoreModules/Avatar/Gods/GodsModule.cs | 4 +- .../World/Estate/EstateManagementModule.cs | 13 ++--- .../CoreModules/World/Land/LandObject.cs | 5 +- .../CoreModules/World/Sound/SoundModule.cs | 10 +--- .../Region/CoreModules/World/Sun/SunModule.cs | 5 +- .../CoreModules/World/Wind/WindModule.cs | 5 +- .../World/WorldMap/WorldMapModule.cs | 4 +- OpenSim/Region/Framework/Scenes/Scene.cs | 58 ++++++++++--------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 16 ++++- .../Region/Framework/Scenes/SceneManager.cs | 9 ++- .../Avatar/Concierge/ConciergeModule.cs | 5 +- .../RegionCombinerModule.cs | 4 +- .../Shared/Api/Implementation/LSL_Api.cs | 20 +++---- 14 files changed, 78 insertions(+), 87 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 4359c01d5d..2cd71c4e87 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -279,12 +279,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat HashSet receiverIDs = new HashSet(); - ((Scene)c.Scene).ForEachScenePresence( + ((Scene)c.Scene).ForEachRootScenePresence( delegate(ScenePresence presence) - { - // ignore chat from child agents - if (presence.IsChildAgent) return; - + { IClientAPI client = presence.ControllingClient; // don't forward SayOwner chat from objects to diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 5ec64d5141..562c3b1687 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs @@ -140,10 +140,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods // This is a bit crude. It seems the client will be null before it actually stops the thread // The thread will kill itself eventually :/ // Is there another way to make sure *all* clients get this 'inter region' message? - m_scene.ForEachScenePresence( + m_scene.ForEachRootScenePresence( delegate(ScenePresence p) { - if (p.UUID != godID && !p.IsChildAgent) + if (p.UUID != godID) { // Possibly this should really be p.Close() though that method doesn't send a close // to the client diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index c199a77264..5427b68557 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -658,17 +658,15 @@ namespace OpenSim.Region.CoreModules.World.Estate if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) return; - Scene.ForEachScenePresence(delegate(ScenePresence sp) + Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.UUID != senderID) { - ScenePresence p = Scene.GetScenePresence(sp.UUID); // make sure they are still there, we could be working down a long list // Also make sure they are actually in the region - if (p != null && !p.IsChildAgent) - { + ScenePresence p; + if(Scene.TryGetScenePresence(sp.UUID, out p)) Scene.TeleportClientHome(p.UUID, p.ControllingClient); - } } }); } @@ -929,10 +927,9 @@ namespace OpenSim.Region.CoreModules.World.Estate public void sendRegionInfoPacketToAll() { - Scene.ForEachScenePresence(delegate(ScenePresence sp) + Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - HandleRegionInfoRequest(sp.ControllingClient); + HandleRegionInfoRequest(sp.ControllingClient); }); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 8c40171943..0da0de3b64 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -476,11 +476,8 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandUpdateToAvatarsOverMe(bool snap_selection) { - m_scene.ForEachScenePresence(delegate(ScenePresence avatar) + m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar) { - if (avatar.IsChildAgent) - return; - ILandObject over = null; try { diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 22ffcd6335..93b10052fc 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -70,11 +70,8 @@ namespace OpenSim.Region.CoreModules.World.Sound SceneObjectGroup grp = part.ParentGroup; - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (sp.IsChildAgent) - return; - double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance return; @@ -122,11 +119,8 @@ namespace OpenSim.Region.CoreModules.World.Sound } } - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (sp.IsChildAgent) - return; - double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance return; diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 4e14c73a25..d2c128922b 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs @@ -488,12 +488,9 @@ namespace OpenSim.Region.CoreModules private void SunUpdateToAllClients() { - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - { SunToClient(sp.ControllingClient); - } }); } diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 6bac5559e9..bea5db1cac 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs @@ -435,10 +435,9 @@ namespace OpenSim.Region.CoreModules m_frameLastUpdateClientArray = m_frame; } - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - sp.ControllingClient.SendWindData(windSpeeds); + sp.ControllingClient.SendWindData(windSpeeds); }); } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 857079cb89..509c0d8e46 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -401,10 +401,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } else { - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { // Don't send a green dot for yourself - if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId) + if (sp.UUID != remoteClient.AgentId) { mapitem = new mapItemReply(); mapitem.x = (uint)(xstart + sp.AbsolutePosition.X); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e43185d23b..302103ae78 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -893,22 +893,17 @@ namespace OpenSim.Region.Framework.Scenes try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + ForEachRootScenePresence(delegate(ScenePresence agent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - List old = new List(); - old.Add(otherRegion.RegionHandle); - agent.DropOldNeighbours(old); - if (m_teleportModule != null) - m_teleportModule.EnableChildAgent(agent, otherRegion); - } - } - ); + List old = new List(); + old.Add(otherRegion.RegionHandle); + agent.DropOldNeighbours(old); + if (m_teleportModule != null) + m_teleportModule.EnableChildAgent(agent, otherRegion); + }); } catch (NullReferenceException) { @@ -1043,16 +1038,11 @@ namespace OpenSim.Region.Framework.Scenes GridRegion r = new GridRegion(region); try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - if (m_teleportModule != null) - m_teleportModule.EnableChildAgent(agent, r); - } - } - ); + ForEachRootScenePresence(delegate(ScenePresence agent) + { + if (m_teleportModule != null) + m_teleportModule.EnableChildAgent(agent, r); + }); } catch (NullReferenceException) { @@ -1456,11 +1446,10 @@ namespace OpenSim.Region.Framework.Scenes /// Stats on the Simulator's performance private void SendSimStatsPackets(SimStats stats) { - ForEachScenePresence( + ForEachRootScenePresence( delegate(ScenePresence agent) { - if (!agent.IsChildAgent) - agent.ControllingClient.SendSimStats(stats); + agent.ControllingClient.SendSimStats(stats); } ); } @@ -4289,6 +4278,19 @@ namespace OpenSim.Region.Framework.Scenes return cp.IsChildAgent; } + /// + /// Performs action on all ROOT (not child) scene presences. + /// This is just a shortcut function since frequently actions only appy to root SPs + /// + /// + public void ForEachRootScenePresence(Action action) + { + if(m_sceneGraph != null) + { + m_sceneGraph.ForEachRootScenePresence(action); + } + } + /// /// Performs action on all scene presences. /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index caec704fb5..542bd51274 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1190,7 +1190,21 @@ namespace OpenSim.Region.Framework.Scenes } } } - + + /// + /// Performs action on all ROOT (not child) scene presences. + /// This is just a shortcut function since frequently actions only appy to root SPs + /// + /// + public void ForEachRootScenePresence(Action action) + { + ForEachScenePresence(delegate(ScenePresence sp) + { + if (!sp.IsChildAgent) + action(sp); + }); + } + /// /// Performs action on all scene presences. This can ultimately run the actions in parallel but /// any delegates passed in will need to implement their own locking on data they reference and diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index a58b87d9d1..3bfd8669e6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -458,9 +458,9 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { - if (!scenePresence.IsChildAgent && (name == null || scenePresence.Name == name)) + if (name == null || scenePresence.Name == name) { m_log.DebugFormat("Packet debug for {0} {1} set to {2}", scenePresence.Firstname, @@ -481,10 +481,9 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { - if (!scenePresence.IsChildAgent) - avatars.Add(scenePresence); + avatars.Add(scenePresence); }); } ); diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index 0d6313acb4..e22618dff3 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs @@ -373,13 +373,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge scene.GetRootAgentCount(), scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, DateTime.UtcNow.ToString("s"))); - scene.ForEachScenePresence(delegate(ScenePresence sp) + scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - { list.Append(String.Format(" \n", sp.Name, sp.UUID)); list.Append(""); - } }); string payload = list.ToString(); diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 4a24c7d223..92cbbc68f1 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -711,10 +711,8 @@ namespace OpenSim.Region.RegionCombinerModule List CoarseLocations = new List(); List AvatarUUIDs = new List(); - connectiondata.RegionScene.ForEachScenePresence(delegate(ScenePresence sp) + connectiondata.RegionScene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (sp.IsChildAgent) - return; if (sp.UUID != presence.UUID) { if (sp.ParentID != 0) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 82701ce636..83c3b78d65 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3723,9 +3723,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); List keytable = new List(); // parse for sitting avatare-uuids - World.ForEachScenePresence(delegate(ScenePresence presence) + World.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) + if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) keytable.Add(presence.UUID); }); @@ -3785,9 +3785,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // parse for sitting avatare-names List nametable = new List(); - World.ForEachScenePresence(delegate(ScenePresence presence) + World.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) + if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) nametable.Add(presence.ControllingClient.Name); }); @@ -7568,9 +7568,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); int avatarCount = 0; - World.ForEachScenePresence(delegate(ScenePresence presence) + World.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) + if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) avatarCount++; }); @@ -9336,9 +9336,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api landObject.SetMediaUrl(url); // now send to all (non-child) agents in the parcel - World.ForEachScenePresence(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent && (sp.currentParcelUUID == landData.GlobalID)) + if (sp.currentParcelUUID == landData.GlobalID) { sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, landData.MediaID, @@ -9369,9 +9369,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence == null) { // send to all (non-child) agents in the parcel - World.ForEachScenePresence(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent && (sp.currentParcelUUID == landData.GlobalID)) + if (sp.currentParcelUUID == landData.GlobalID) { sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? (ParcelMediaCommandEnum)commandToSend, From 06577d7299f38c342c9b241c691e647e5329837e Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 01:25:12 -0700 Subject: [PATCH 6/7] Continuation of previous checkin. Found more places where ForEachScenePresence can be changed to ForEachRootScenePresence. --- .../CoreModules/Avatar/Dialog/DialogModule.cs | 10 ++-- .../Framework/Scenes/SceneObjectPart.cs | 9 ++-- .../Region/Framework/Scenes/ScenePresence.cs | 53 ++++++++----------- .../Shared/Api/Implementation/OSSL_Api.cs | 24 ++++----- 4 files changed, 39 insertions(+), 57 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index d2a0860861..3ce446bef5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -98,10 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendGeneralAlert(string message) { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent) - presence.ControllingClient.SendAlertMessage(message); + presence.ControllingClient.SendAlertMessage(message); }); } @@ -163,10 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendNotificationToUsersInRegion( UUID fromAvatarID, string fromAvatarName, string message) { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent) - presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); + presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); }); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c8ecc9bf90..3a4f52e6be 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1440,10 +1440,9 @@ namespace OpenSim.Region.Framework.Scenes if (volume < 0) volume = 0; - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); + sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); }); } @@ -2676,10 +2675,8 @@ namespace OpenSim.Region.Framework.Scenes } } - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (sp.IsChildAgent) - return; if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); }); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ee6c708d3f..3834b7947a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2598,19 +2598,15 @@ namespace OpenSim.Region.Framework.Scenes public void SendOtherAgentsAvatarDataToMe() { int count = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - // only send information about root agents - if (scenePresence.IsChildAgent) - return; + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + { + // only send information about other root agents + if (scenePresence.UUID == UUID) + return; - // only send information about other root agents - if (scenePresence.UUID == UUID) - return; - - scenePresence.SendAvatarDataToAgent(this); - count++; - }); + scenePresence.SendAvatarDataToAgent(this); + count++; + }); m_scene.StatsReporter.AddAgentUpdates(count); } @@ -2644,13 +2640,14 @@ namespace OpenSim.Region.Framework.Scenes int count = 0; m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - if (scenePresence.UUID == UUID) - return; + { + // only send information to other root agents + if (scenePresence.UUID == UUID) + return; - SendAppearanceToAgent(scenePresence); - count++; - }); + SendAppearanceToAgent(scenePresence); + count++; + }); m_scene.StatsReporter.AddAgentUpdates(count); } @@ -2664,19 +2661,15 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID); int count = 0; - m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) - { - // only send information about root agents - if (scenePresence.IsChildAgent) - return; + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + { + // only send information about other root agents + if (scenePresence.UUID == UUID) + return; - // only send information about other root agents - if (scenePresence.UUID == UUID) - return; - - scenePresence.SendAppearanceToAgent(this); - count++; - }); + scenePresence.SendAppearanceToAgent(this); + count++; + }); m_scene.StatsReporter.AddAgentUpdates(count); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3cfc3c94f1..654f1689a7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -873,10 +873,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetAgents"); LSL_List result = new LSL_List(); - World.ForEachScenePresence(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - result.Add(new LSL_String(sp.Name)); + result.Add(new LSL_String(sp.Name)); }); return result; } @@ -2582,11 +2581,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) { - World.ForEachScenePresence(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent && - sp.Firstname == FirstName && - sp.Lastname == SurName) + if (sp.Firstname == FirstName && sp.Lastname == SurName) { // kick client... if (alert != null) @@ -2718,17 +2715,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); LSL_List result = new LSL_List(); - World.ForEachScenePresence(delegate (ScenePresence avatar) + World.ForEachRootScenePresence(delegate (ScenePresence avatar) { if (avatar != null && avatar.UUID != m_host.OwnerID) { - if (avatar.IsChildAgent == false) - { - result.Add(new LSL_String(avatar.UUID.ToString())); - OpenMetaverse.Vector3 ap = avatar.AbsolutePosition; - result.Add(new LSL_Vector(ap.X, ap.Y, ap.Z)); - result.Add(new LSL_String(avatar.Name)); - } + result.Add(new LSL_String(avatar.UUID.ToString())); + OpenMetaverse.Vector3 ap = avatar.AbsolutePosition; + result.Add(new LSL_Vector(ap.X, ap.Y, ap.Z)); + result.Add(new LSL_String(avatar.Name)); } }); From 272bf712796ad8e98e79aee50311a84deaf23d79 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 02:26:37 -0700 Subject: [PATCH 7/7] Removed use of 'is' operator and casting to find the root ScenePresence in MessageTransfer modules and Groups module. --- .../InstantMessage/HGMessageTransferModule.cs | 57 +++++++------------ .../InstantMessage/MessageTransferModule.cs | 50 ++++++---------- .../XmlRpcGroups/GroupsMessagingModule.cs | 15 +++-- .../Avatar/XmlRpcGroups/GroupsModule.cs | 11 ++-- 4 files changed, 52 insertions(+), 81 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index 72b448b9d6..321a70522b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -143,24 +143,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // Try root avatar only first foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) - { -// m_log.DebugFormat( -// "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", -// toAgentID.ToString(), scene.RegionInfo.RegionName); - - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - if (!user.IsChildAgent) - { - // Local message -// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); +// m_log.DebugFormat( +// "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", +// toAgentID.ToString(), scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null && !sp.IsChildAgent) + { + // Local message +// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); - // Message sent - result(true); - return; - } + // Message sent + result(true); + return; } } @@ -168,16 +163,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage foreach (Scene scene in m_Scenes) { // m_log.DebugFormat( -// "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); - - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) - { +// "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", +// toAgentID, scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null) + { // Local message - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); + sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); @@ -231,17 +224,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage bool successful = false; foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(toAgentID); + if(!sp.IsChildAgent) { - ScenePresence user = - (ScenePresence)scene.Entities[toAgentID]; - - if (!user.IsChildAgent) - { - scene.EventManager.TriggerIncomingInstantMessage(gim); - successful = true; - } + scene.EventManager.TriggerIncomingInstantMessage(gim); + successful = true; } } if (!successful) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 45b84f4295..0dad3c4147 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -136,24 +136,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // Try root avatar only first foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) +// m_log.DebugFormat( +// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", +// toAgentID.ToString(), scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null && !sp.IsChildAgent) { -// m_log.DebugFormat( -// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", -// toAgentID.ToString(), scene.RegionInfo.RegionName); - - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - if (!user.IsChildAgent) - { - // Local message -// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); + // Local message +// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); - // Message sent - result(true); - return; - } + // Message sent + result(true); + return; } } @@ -162,15 +157,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { // m_log.DebugFormat( // "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); - - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null) { // Local message - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); + sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); @@ -389,17 +381,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // Trigger the Instant message in the scene. foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null && !sp.IsChildAgent) { - ScenePresence user = - (ScenePresence)scene.Entities[toAgentID]; - - if (!user.IsChildAgent) - { - scene.EventManager.TriggerIncomingInstantMessage(gim); - successful = true; - } + scene.EventManager.TriggerIncomingInstantMessage(gim); + successful = true; } } if (!successful) diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index a12e6ea1ac..10b83e64dd 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -504,19 +504,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Try root avatar first foreach (Scene scene in m_sceneList) { - if (scene.Entities.ContainsKey(agentID) && - scene.Entities[agentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(agentID); + if (sp != null) { - ScenePresence user = (ScenePresence)scene.Entities[agentID]; - if (!user.IsChildAgent) + if (!sp.IsChildAgent) { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); - return user.ControllingClient; + if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); + return sp.ControllingClient; } else { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); - child = user.ControllingClient; + if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); + child = sp.ControllingClient; } } } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 630fcabac3..b2c0f48a28 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -1076,17 +1076,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Try root avatar first foreach (Scene scene in m_sceneList) { - if (scene.Entities.ContainsKey(agentID) && - scene.Entities[agentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(agentID); + if (sp != null) { - ScenePresence user = (ScenePresence)scene.Entities[agentID]; - if (!user.IsChildAgent) + if (!sp.IsChildAgent) { - return user.ControllingClient; + return sp.ControllingClient; } else { - child = user.ControllingClient; + child = sp.ControllingClient; } } }