aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-23 01:02:36 -0700
committerJohn Hurliman2009-10-23 01:02:36 -0700
commit588361e2a2398b963871762c2b5485c6a086cf47 (patch)
tree5be2c6705096817c599075da4e12a0e9b0a4c841 /OpenSim/Region
parentAdded VS2010 support to Prebuild and created runprebuild2010.bat (diff)
downloadopensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.zip
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.gz
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.bz2
opensim-SC_OLD-588361e2a2398b963871762c2b5485c6a086cf47.tar.xz
Experimental change to use an immutable array for iterating ScenePresences, avoiding locking and copying the list each time it is accessed
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs141
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs160
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs53
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs121
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs21
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs13
-rw-r--r--OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs14
13 files changed, 308 insertions, 284 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 5acf25f..e81ff4b 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4434,6 +4434,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4434 protected virtual void RegisterLocalPacketHandlers() 4434 protected virtual void RegisterLocalPacketHandlers()
4435 { 4435 {
4436 AddLocalPacketHandler(PacketType.LogoutRequest, Logout); 4436 AddLocalPacketHandler(PacketType.LogoutRequest, Logout);
4437 AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate);
4437 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); 4438 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect);
4438 AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); 4439 AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached);
4439 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); 4440 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate);
@@ -4446,6 +4447,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4446 4447
4447 #region Packet Handlers 4448 #region Packet Handlers
4448 4449
4450 private bool HandleAgentUpdate(IClientAPI sener, Packet Pack)
4451 {
4452 if (OnAgentUpdate != null)
4453 {
4454 bool update = false;
4455 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
4456
4457 #region Packet Session and User Check
4458 if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId)
4459 return false;
4460 #endregion
4461
4462 AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
4463
4464 // We can only check when we have something to check
4465 // against.
4466
4467 if (lastarg != null)
4468 {
4469 update =
4470 (
4471 (x.BodyRotation != lastarg.BodyRotation) ||
4472 (x.CameraAtAxis != lastarg.CameraAtAxis) ||
4473 (x.CameraCenter != lastarg.CameraCenter) ||
4474 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4475 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
4476 (x.ControlFlags != lastarg.ControlFlags) ||
4477 (x.Far != lastarg.Far) ||
4478 (x.Flags != lastarg.Flags) ||
4479 (x.State != lastarg.State) ||
4480 (x.HeadRotation != lastarg.HeadRotation) ||
4481 (x.SessionID != lastarg.SessionID) ||
4482 (x.AgentID != lastarg.AgentID)
4483 );
4484 }
4485 else
4486 update = true;
4487
4488 // These should be ordered from most-likely to
4489 // least likely to change. I've made an initial
4490 // guess at that.
4491
4492 if (update)
4493 {
4494 AgentUpdateArgs arg = new AgentUpdateArgs();
4495 arg.AgentID = x.AgentID;
4496 arg.BodyRotation = x.BodyRotation;
4497 arg.CameraAtAxis = x.CameraAtAxis;
4498 arg.CameraCenter = x.CameraCenter;
4499 arg.CameraLeftAxis = x.CameraLeftAxis;
4500 arg.CameraUpAxis = x.CameraUpAxis;
4501 arg.ControlFlags = x.ControlFlags;
4502 arg.Far = x.Far;
4503 arg.Flags = x.Flags;
4504 arg.HeadRotation = x.HeadRotation;
4505 arg.SessionID = x.SessionID;
4506 arg.State = x.State;
4507 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
4508 lastarg = arg; // save this set of arguments for nexttime
4509 if (handlerAgentUpdate != null)
4510 OnAgentUpdate(this, arg);
4511
4512 handlerAgentUpdate = null;
4513 }
4514 }
4515
4516 return true;
4517 }
4518
4449 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack) 4519 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
4450 { 4520 {
4451 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack; 4521 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
@@ -5631,77 +5701,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5631 5701
5632 break; 5702 break;
5633 5703
5634 case PacketType.AgentUpdate:
5635 if (OnAgentUpdate != null)
5636 {
5637 bool update = false;
5638 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
5639
5640 #region Packet Session and User Check
5641 if (m_checkPackets)
5642 {
5643 if (agenUpdate.AgentData.SessionID != SessionId ||
5644 agenUpdate.AgentData.AgentID != AgentId)
5645 break;
5646 }
5647 #endregion
5648
5649 AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
5650
5651 // We can only check when we have something to check
5652 // against.
5653
5654 if (lastarg != null)
5655 {
5656 update =
5657 (
5658 (x.BodyRotation != lastarg.BodyRotation) ||
5659 (x.CameraAtAxis != lastarg.CameraAtAxis) ||
5660 (x.CameraCenter != lastarg.CameraCenter) ||
5661 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
5662 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
5663 (x.ControlFlags != lastarg.ControlFlags) ||
5664 (x.Far != lastarg.Far) ||
5665 (x.Flags != lastarg.Flags) ||
5666 (x.State != lastarg.State) ||
5667 (x.HeadRotation != lastarg.HeadRotation) ||
5668 (x.SessionID != lastarg.SessionID) ||
5669 (x.AgentID != lastarg.AgentID)
5670 );
5671 }
5672 else
5673 update = true;
5674
5675 // These should be ordered from most-likely to
5676 // least likely to change. I've made an initial
5677 // guess at that.
5678
5679 if (update)
5680 {
5681 AgentUpdateArgs arg = new AgentUpdateArgs();
5682 arg.AgentID = x.AgentID;
5683 arg.BodyRotation = x.BodyRotation;
5684 arg.CameraAtAxis = x.CameraAtAxis;
5685 arg.CameraCenter = x.CameraCenter;
5686 arg.CameraLeftAxis = x.CameraLeftAxis;
5687 arg.CameraUpAxis = x.CameraUpAxis;
5688 arg.ControlFlags = x.ControlFlags;
5689 arg.Far = x.Far;
5690 arg.Flags = x.Flags;
5691 arg.HeadRotation = x.HeadRotation;
5692 arg.SessionID = x.SessionID;
5693 arg.State = x.State;
5694 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
5695 lastarg = arg; // save this set of arguments for nexttime
5696 if (handlerAgentUpdate != null)
5697 OnAgentUpdate(this, arg);
5698
5699 handlerAgentUpdate = null;
5700 }
5701
5702 }
5703 break;
5704
5705 case PacketType.AgentAnimation: 5704 case PacketType.AgentAnimation:
5706 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; 5705 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
5707 5706
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index 9387bce..61b6d65 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -96,12 +96,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
96 else 96 else
97 { 97 {
98 bool foundResult = false; 98 bool foundResult = false;
99 string resultstring = ""; 99 string resultstring = String.Empty;
100 List<ScenePresence> allav = DeadAvatar.Scene.GetScenePresences(); 100 ScenePresence[] allav = DeadAvatar.Scene.GetScenePresences();
101 try 101 try
102 { 102 {
103 foreach (ScenePresence av in allav) 103 for (int i = 0; i < allav.Length; i++)
104 { 104 {
105 ScenePresence av = allav[i];
106
105 if (av.LocalId == killerObjectLocalID) 107 if (av.LocalId == killerObjectLocalID)
106 { 108 {
107 av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); 109 av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index ebebaf9..72ec869 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -85,10 +85,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
85 85
86 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 86 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
87 { 87 {
88 List<ScenePresence> presenceList = m_scene.GetScenePresences(); 88 ScenePresence[] presenceList = m_scene.GetScenePresences();
89 89
90 foreach (ScenePresence presence in presenceList) 90 for (int i = 0; i < presenceList.Length; i++)
91 { 91 {
92 ScenePresence presence = presenceList[i];
93
92 if (presence.Firstname == firstName && presence.Lastname == lastName) 94 if (presence.Firstname == firstName && presence.Lastname == lastName)
93 { 95 {
94 presence.ControllingClient.SendAgentAlertMessage(message, modal); 96 presence.ControllingClient.SendAgentAlertMessage(message, modal);
@@ -99,10 +101,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
99 101
100 public void SendGeneralAlert(string message) 102 public void SendGeneralAlert(string message)
101 { 103 {
102 List<ScenePresence> presenceList = m_scene.GetScenePresences(); 104 ScenePresence[] presenceList = m_scene.GetScenePresences();
103 105
104 foreach (ScenePresence presence in presenceList) 106 for (int i = 0; i < presenceList.Length; i++)
105 { 107 {
108 ScenePresence presence = presenceList[i];
109
106 if (!presence.IsChildAgent) 110 if (!presence.IsChildAgent)
107 presence.ControllingClient.SendAlertMessage(message); 111 presence.ControllingClient.SendAlertMessage(message);
108 } 112 }
@@ -150,10 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
150 public void SendNotificationToUsersInRegion( 154 public void SendNotificationToUsersInRegion(
151 UUID fromAvatarID, string fromAvatarName, string message) 155 UUID fromAvatarID, string fromAvatarName, string message)
152 { 156 {
153 List<ScenePresence> presenceList = m_scene.GetScenePresences(); 157 ScenePresence[] presences = m_scene.GetScenePresences();
154 158
155 foreach (ScenePresence presence in presenceList) 159 for (int i = 0; i < presences.Length; i++)
156 { 160 {
161 ScenePresence presence = presences[i];
157 if (!presence.IsChildAgent) 162 if (!presence.IsChildAgent)
158 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); 163 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
159 } 164 }
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 3bb162e..e3a395e 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -414,9 +414,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
414 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) 414 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
415 { 415 {
416 // Get a fresh list that will not change as people get teleported away 416 // Get a fresh list that will not change as people get teleported away
417 List<ScenePresence> prescences = m_scene.GetScenePresences(); 417 ScenePresence[] presences = m_scene.GetScenePresences();
418 foreach (ScenePresence p in prescences) 418
419 for (int i = 0; i < presences.Length; i++)
419 { 420 {
421 ScenePresence p = presences[i];
422
420 if (p.UUID != senderID) 423 if (p.UUID != senderID)
421 { 424 {
422 // make sure they are still there, we could be working down a long list 425 // make sure they are still there, we could be working down a long list
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4b87f92..d5e3445 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -253,7 +253,7 @@ namespace OpenSim.Region.Framework.Scenes
253 protected int m_fps = 10; 253 protected int m_fps = 10;
254 protected int m_frame = 0; 254 protected int m_frame = 0;
255 protected float m_timespan = 0.089f; 255 protected float m_timespan = 0.089f;
256 protected DateTime m_lastupdate = DateTime.Now; 256 protected DateTime m_lastupdate = DateTime.UtcNow;
257 257
258 private int m_update_physics = 1; 258 private int m_update_physics = 1;
259 private int m_update_entitymovement = 1; 259 private int m_update_entitymovement = 1;
@@ -1014,7 +1014,7 @@ namespace OpenSim.Region.Framework.Scenes
1014//#endif 1014//#endif
1015 maintc = Environment.TickCount; 1015 maintc = Environment.TickCount;
1016 1016
1017 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; 1017 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1018 float physicsFPS = 0; 1018 float physicsFPS = 0;
1019 1019
1020 frameMS = Environment.TickCount; 1020 frameMS = Environment.TickCount;
@@ -1137,7 +1137,7 @@ namespace OpenSim.Region.Framework.Scenes
1137 } 1137 }
1138 m_timedilation = tmpval; 1138 m_timedilation = tmpval;
1139 1139
1140 m_lastupdate = DateTime.Now; 1140 m_lastupdate = DateTime.UtcNow;
1141 } 1141 }
1142 maintc = Environment.TickCount - maintc; 1142 maintc = Environment.TickCount - maintc;
1143 maintc = (int)(m_timespan * 1000) - maintc; 1143 maintc = (int)(m_timespan * 1000) - maintc;
@@ -3496,9 +3496,7 @@ namespace OpenSim.Region.Framework.Scenes
3496 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3496 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3497 { 3497 {
3498 ScenePresence presence; 3498 ScenePresence presence;
3499 3499 m_sceneGraph.TryGetAvatar(agentID, out presence);
3500 lock (m_sceneGraph.ScenePresences)
3501 m_sceneGraph.ScenePresences.TryGetValue(agentID, out presence);
3502 3500
3503 if (presence != null) 3501 if (presence != null)
3504 { 3502 {
@@ -3709,8 +3707,7 @@ namespace OpenSim.Region.Framework.Scenes
3709 Vector3 lookAt, uint teleportFlags) 3707 Vector3 lookAt, uint teleportFlags)
3710 { 3708 {
3711 ScenePresence sp; 3709 ScenePresence sp;
3712 lock (m_sceneGraph.ScenePresences) 3710 m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
3713 m_sceneGraph.ScenePresences.TryGetValue(remoteClient.AgentId, out sp);
3714 3711
3715 if (sp != null) 3712 if (sp != null)
3716 { 3713 {
@@ -4112,7 +4109,7 @@ namespace OpenSim.Region.Framework.Scenes
4112 /// This list is a new object, so it can be iterated over without locking. 4109 /// This list is a new object, so it can be iterated over without locking.
4113 /// </summary> 4110 /// </summary>
4114 /// <returns></returns> 4111 /// <returns></returns>
4115 public List<ScenePresence> GetScenePresences() 4112 public ScenePresence[] GetScenePresences()
4116 { 4113 {
4117 return m_sceneGraph.GetScenePresences(); 4114 return m_sceneGraph.GetScenePresences();
4118 } 4115 }
@@ -4159,15 +4156,13 @@ namespace OpenSim.Region.Framework.Scenes
4159 public void ForEachScenePresence(Action<ScenePresence> action) 4156 public void ForEachScenePresence(Action<ScenePresence> action)
4160 { 4157 {
4161 // We don't want to try to send messages if there are no avatars. 4158 // We don't want to try to send messages if there are no avatars.
4162 if (m_sceneGraph != null && m_sceneGraph.ScenePresences != null) 4159 if (m_sceneGraph != null)
4163 { 4160 {
4164 try 4161 try
4165 { 4162 {
4166 List<ScenePresence> presenceList = GetScenePresences(); 4163 ScenePresence[] presences = GetScenePresences();
4167 foreach (ScenePresence presence in presenceList) 4164 for (int i = 0; i < presences.Length; i++)
4168 { 4165 action(presences[i]);
4169 action(presence);
4170 }
4171 } 4166 }
4172 catch (Exception e) 4167 catch (Exception e)
4173 { 4168 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index deee6c3..db055f9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -66,7 +66,9 @@ namespace OpenSim.Region.Framework.Scenes
66 66
67 #region Fields 67 #region Fields
68 68
69 protected internal Dictionary<UUID, ScenePresence> ScenePresences = new Dictionary<UUID, ScenePresence>(); 69 protected Dictionary<UUID, ScenePresence> m_scenePresences = new Dictionary<UUID, ScenePresence>();
70 protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0];
71
70 // SceneObjects is not currently populated or used. 72 // SceneObjects is not currently populated or used.
71 //public Dictionary<UUID, SceneObjectGroup> SceneObjects; 73 //public Dictionary<UUID, SceneObjectGroup> SceneObjects;
72 protected internal EntityManager Entities = new EntityManager(); 74 protected internal EntityManager Entities = new EntityManager();
@@ -126,10 +128,12 @@ namespace OpenSim.Region.Framework.Scenes
126 128
127 protected internal void Close() 129 protected internal void Close()
128 { 130 {
129 lock (ScenePresences) 131 lock (m_scenePresences)
130 { 132 {
131 ScenePresences.Clear(); 133 m_scenePresences.Clear();
134 m_scenePresenceArray = new ScenePresence[0];
132 } 135 }
136
133 lock (m_dictionary_lock) 137 lock (m_dictionary_lock)
134 { 138 {
135 SceneObjectGroupsByFullID.Clear(); 139 SceneObjectGroupsByFullID.Clear();
@@ -157,11 +161,9 @@ namespace OpenSim.Region.Framework.Scenes
157 161
158 protected internal void UpdatePresences() 162 protected internal void UpdatePresences()
159 { 163 {
160 List<ScenePresence> updateScenePresences = GetScenePresences(); 164 ScenePresence[] updateScenePresences = GetScenePresences();
161 foreach (ScenePresence pres in updateScenePresences) 165 for (int i = 0; i < updateScenePresences.Length; i++)
162 { 166 updateScenePresences[i].Update();
163 pres.Update();
164 }
165 } 167 }
166 168
167 protected internal float UpdatePhysics(double elapsed) 169 protected internal float UpdatePhysics(double elapsed)
@@ -190,15 +192,9 @@ namespace OpenSim.Region.Framework.Scenes
190 192
191 protected internal void UpdateScenePresenceMovement() 193 protected internal void UpdateScenePresenceMovement()
192 { 194 {
193 List<ScenePresence> moveEntities = GetScenePresences(); 195 ScenePresence[] moveEntities = GetScenePresences();
194 196 for (int i = 0; i < moveEntities.Length; i++)
195 foreach (EntityBase entity in moveEntities) 197 moveEntities[i].UpdateMovement();
196 {
197 //cfk. This throws occaisional exceptions on a heavily used region
198 //and I added this null check to try to preclude the exception.
199 if (entity != null)
200 entity.UpdateMovement();
201 }
202 } 198 }
203 199
204 #endregion 200 #endregion
@@ -645,9 +641,34 @@ namespace OpenSim.Region.Framework.Scenes
645 641
646 Entities[presence.UUID] = presence; 642 Entities[presence.UUID] = presence;
647 643
648 lock (ScenePresences) 644 lock (m_scenePresences)
649 { 645 {
650 ScenePresences[presence.UUID] = presence; 646 if (!m_scenePresences.ContainsKey(presence.UUID))
647 {
648 m_scenePresences.Add(presence.UUID, presence);
649
650 // Create a new array of ScenePresence references
651 int oldLength = m_scenePresenceArray.Length;
652 ScenePresence[] newArray = new ScenePresence[oldLength + 1];
653 Array.Copy(m_scenePresenceArray, newArray, oldLength);
654 newArray[oldLength] = presence;
655 m_scenePresenceArray = newArray;
656 }
657 else
658 {
659 m_scenePresences[presence.UUID] = presence;
660
661 // Do a linear search through the array of ScenePresence references
662 // and update the modified entry
663 for (int i = 0; i < m_scenePresenceArray.Length; i++)
664 {
665 if (m_scenePresenceArray[i].UUID == presence.UUID)
666 {
667 m_scenePresenceArray[i] = presence;
668 break;
669 }
670 }
671 }
651 } 672 }
652 } 673 }
653 674
@@ -663,16 +684,30 @@ namespace OpenSim.Region.Framework.Scenes
663 agentID); 684 agentID);
664 } 685 }
665 686
666 lock (ScenePresences) 687 lock (m_scenePresences)
667 { 688 {
668 if (!ScenePresences.Remove(agentID)) 689 if (m_scenePresences.Remove(agentID))
690 {
691 // Copy all of the elements from the previous array
692 // into the new array except the removed element
693 int oldLength = m_scenePresenceArray.Length;
694 ScenePresence[] newArray = new ScenePresence[oldLength - 1];
695 int j = 0;
696 for (int i = 0; i < m_scenePresenceArray.Length; i++)
697 {
698 ScenePresence presence = m_scenePresenceArray[i];
699 if (presence.UUID != agentID)
700 {
701 newArray[j] = presence;
702 ++j;
703 }
704 }
705 m_scenePresenceArray = newArray;
706 }
707 else
669 { 708 {
670 m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 709 m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
671 } 710 }
672// else
673// {
674// m_log.InfoFormat("[SCENE] Removed scene presence {0} from scene presences list", agentID);
675// }
676 } 711 }
677 } 712 }
678 713
@@ -704,20 +739,21 @@ namespace OpenSim.Region.Framework.Scenes
704 739
705 public void RecalculateStats() 740 public void RecalculateStats()
706 { 741 {
707 List<ScenePresence> SPList = GetScenePresences(); 742 ScenePresence[] presences = GetScenePresences();
708 int rootcount = 0; 743 int rootcount = 0;
709 int childcount = 0; 744 int childcount = 0;
710 745
711 foreach (ScenePresence user in SPList) 746 for (int i = 0; i < presences.Length; i++)
712 { 747 {
748 ScenePresence user = presences[i];
713 if (user.IsChildAgent) 749 if (user.IsChildAgent)
714 childcount++; 750 ++childcount;
715 else 751 else
716 rootcount++; 752 ++rootcount;
717 } 753 }
754
718 m_numRootAgents = rootcount; 755 m_numRootAgents = rootcount;
719 m_numChildAgents = childcount; 756 m_numChildAgents = childcount;
720
721 } 757 }
722 758
723 public int GetChildAgentCount() 759 public int GetChildAgentCount()
@@ -767,12 +803,9 @@ namespace OpenSim.Region.Framework.Scenes
767 /// locking is required to iterate over it. 803 /// locking is required to iterate over it.
768 /// </summary> 804 /// </summary>
769 /// <returns></returns> 805 /// <returns></returns>
770 protected internal List<ScenePresence> GetScenePresences() 806 protected internal ScenePresence[] GetScenePresences()
771 { 807 {
772 lock (ScenePresences) 808 return m_scenePresenceArray;
773 {
774 return new List<ScenePresence>(ScenePresences.Values);
775 }
776 } 809 }
777 810
778 protected internal List<ScenePresence> GetAvatars() 811 protected internal List<ScenePresence> GetAvatars()
@@ -817,14 +850,13 @@ namespace OpenSim.Region.Framework.Scenes
817 // No locking of scene presences here since we're passing back a list... 850 // No locking of scene presences here since we're passing back a list...
818 851
819 List<ScenePresence> result = new List<ScenePresence>(); 852 List<ScenePresence> result = new List<ScenePresence>();
820 List<ScenePresence> ScenePresencesList = GetScenePresences(); 853 ScenePresence[] scenePresences = GetScenePresences();
821 854
822 foreach (ScenePresence avatar in ScenePresencesList) 855 for (int i = 0; i < scenePresences.Length; i++)
823 { 856 {
857 ScenePresence avatar = scenePresences[i];
824 if (filter(avatar)) 858 if (filter(avatar))
825 {
826 result.Add(avatar); 859 result.Add(avatar);
827 }
828 } 860 }
829 861
830 return result; 862 return result;
@@ -839,9 +871,9 @@ namespace OpenSim.Region.Framework.Scenes
839 { 871 {
840 ScenePresence sp; 872 ScenePresence sp;
841 873
842 lock (ScenePresences) 874 lock (m_scenePresences)
843 { 875 {
844 ScenePresences.TryGetValue(agentID, out sp); 876 m_scenePresences.TryGetValue(agentID, out sp);
845 } 877 }
846 878
847 return sp; 879 return sp;
@@ -1000,48 +1032,24 @@ namespace OpenSim.Region.Framework.Scenes
1000 1032
1001 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 1033 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
1002 { 1034 {
1003 ScenePresence presence; 1035 lock (m_scenePresences)
1004 1036 return m_scenePresences.TryGetValue(avatarId, out avatar);
1005 lock (ScenePresences)
1006 {
1007 if (ScenePresences.TryGetValue(avatarId, out presence))
1008 {
1009 avatar = presence;
1010 return true;
1011
1012 //if (!presence.IsChildAgent)
1013 //{
1014 // avatar = presence;
1015 // return true;
1016 //}
1017 //else
1018 //{
1019 // m_log.WarnFormat(
1020 // "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!",
1021 // avatarId, m_parentScene.RegionInfo.RegionName);
1022 //}
1023 }
1024 }
1025
1026 avatar = null;
1027 return false;
1028 } 1037 }
1029 1038
1030 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 1039 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
1031 { 1040 {
1032 lock (ScenePresences) 1041 ScenePresence[] presences = GetScenePresences();
1042
1043 for (int i = 0; i < presences.Length; i++)
1033 { 1044 {
1034 foreach (ScenePresence presence in ScenePresences.Values) 1045 ScenePresence presence = presences[i];
1046
1047 if (!presence.IsChildAgent)
1035 { 1048 {
1036 if (!presence.IsChildAgent) 1049 if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0)
1037 { 1050 {
1038 string name = presence.ControllingClient.Name; 1051 avatar = presence;
1039 1052 return true;
1040 if (String.Compare(avatarName, name, true) == 0)
1041 {
1042 avatar = presence;
1043 return true;
1044 }
1045 } 1053 }
1046 } 1054 }
1047 } 1055 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 3097929..dfaa7ea 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -411,41 +411,46 @@ namespace OpenSim.Region.Framework.Scenes
411 /// <param name="newDebug"></param> 411 /// <param name="newDebug"></param>
412 public void SetDebugPacketLevelOnCurrentScene(int newDebug) 412 public void SetDebugPacketLevelOnCurrentScene(int newDebug)
413 { 413 {
414 ForEachCurrentScene(delegate(Scene scene) 414 ForEachCurrentScene(
415 { 415 delegate(Scene scene)
416 List<ScenePresence> scenePresences = scene.GetScenePresences(); 416 {
417 ScenePresence[] scenePresences = scene.GetScenePresences();
418
419 for (int i = 0; i < scenePresences.Length; i++)
420 {
421 ScenePresence scenePresence = scenePresences[i];
417 422
418 foreach (ScenePresence scenePresence in scenePresences) 423 if (!scenePresence.IsChildAgent)
419 { 424 {
420 if (!scenePresence.IsChildAgent) 425 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
421 { 426 scenePresence.Firstname,
422 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", 427 scenePresence.Lastname,
423 scenePresence.Firstname, 428 newDebug);
424 scenePresence.Lastname,
425 newDebug);
426 429
427 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); 430 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
428 } 431 }
429 } 432 }
430 }); 433 }
434 );
431 } 435 }
432 436
433 public List<ScenePresence> GetCurrentSceneAvatars() 437 public List<ScenePresence> GetCurrentSceneAvatars()
434 { 438 {
435 List<ScenePresence> avatars = new List<ScenePresence>(); 439 List<ScenePresence> avatars = new List<ScenePresence>();
436 440
437 ForEachCurrentScene(delegate(Scene scene) 441 ForEachCurrentScene(
438 { 442 delegate(Scene scene)
439 List<ScenePresence> scenePresences = scene.GetScenePresences();
440
441 foreach (ScenePresence scenePresence in scenePresences)
442 { 443 {
443 if (!scenePresence.IsChildAgent) 444 ScenePresence[] scenePresences = scene.GetScenePresences();
445
446 for (int i = 0; i < scenePresences.Length; i++)
444 { 447 {
445 avatars.Add(scenePresence); 448 ScenePresence scenePresence = scenePresences[i];
449 if (!scenePresence.IsChildAgent)
450 avatars.Add(scenePresence);
446 } 451 }
447 } 452 }
448 }); 453 );
449 454
450 return avatars; 455 return avatars;
451 } 456 }
@@ -456,7 +461,7 @@ namespace OpenSim.Region.Framework.Scenes
456 461
457 ForEachCurrentScene(delegate(Scene scene) 462 ForEachCurrentScene(delegate(Scene scene)
458 { 463 {
459 List<ScenePresence> scenePresences = scene.GetScenePresences(); 464 ScenePresence[] scenePresences = scene.GetScenePresences();
460 presences.AddRange(scenePresences); 465 presences.AddRange(scenePresences);
461 }); 466 });
462 467
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 69b3ded..4f19761 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1182,8 +1182,8 @@ namespace OpenSim.Region.Framework.Scenes
1182 { 1182 {
1183// part.Inventory.RemoveScriptInstances(); 1183// part.Inventory.RemoveScriptInstances();
1184 1184
1185 List<ScenePresence> avatars = Scene.GetScenePresences(); 1185 ScenePresence[] avatars = Scene.GetScenePresences();
1186 for (int i = 0; i < avatars.Count; i++) 1186 for (int i = 0; i < avatars.Length; i++)
1187 { 1187 {
1188 if (avatars[i].ParentID == LocalId) 1188 if (avatars[i].ParentID == LocalId)
1189 { 1189 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 32171a0..7193002 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1077,8 +1077,8 @@ if (m_shape != null) {
1077 1077
1078 private void SendObjectPropertiesToClient(UUID AgentID) 1078 private void SendObjectPropertiesToClient(UUID AgentID)
1079 { 1079 {
1080 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1080 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1081 for (int i = 0; i < avatars.Count; i++) 1081 for (int i = 0; i < avatars.Length; i++)
1082 { 1082 {
1083 // Ugly reference :( 1083 // Ugly reference :(
1084 if (avatars[i].UUID == AgentID) 1084 if (avatars[i].UUID == AgentID)
@@ -1140,8 +1140,8 @@ if (m_shape != null) {
1140 /// </summary> 1140 /// </summary>
1141 public void AddFullUpdateToAllAvatars() 1141 public void AddFullUpdateToAllAvatars()
1142 { 1142 {
1143 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1143 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1144 for (int i = 0; i < avatars.Count; i++) 1144 for (int i = 0; i < avatars.Length; i++)
1145 { 1145 {
1146 avatars[i].SceneViewer.QueuePartForUpdate(this); 1146 avatars[i].SceneViewer.QueuePartForUpdate(this);
1147 } 1147 }
@@ -1165,8 +1165,8 @@ if (m_shape != null) {
1165 /// Terse updates 1165 /// Terse updates
1166 public void AddTerseUpdateToAllAvatars() 1166 public void AddTerseUpdateToAllAvatars()
1167 { 1167 {
1168 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1168 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1169 for (int i = 0; i < avatars.Count; i++) 1169 for (int i = 0; i < avatars.Length; i++)
1170 { 1170 {
1171 avatars[i].SceneViewer.QueuePartForUpdate(this); 1171 avatars[i].SceneViewer.QueuePartForUpdate(this);
1172 } 1172 }
@@ -1894,24 +1894,24 @@ if (m_shape != null) {
1894 } 1894 }
1895 else 1895 else
1896 { 1896 {
1897 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 1897 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
1898 if (avlist != null) 1898
1899 for (int i = 0; i < avlist.Length; i++)
1899 { 1900 {
1900 foreach (ScenePresence av in avlist) 1901 ScenePresence av = avlist[i];
1902
1903 if (av.LocalId == localId)
1901 { 1904 {
1902 if (av.LocalId == localId) 1905 DetectedObject detobj = new DetectedObject();
1903 { 1906 detobj.keyUUID = av.UUID;
1904 DetectedObject detobj = new DetectedObject(); 1907 detobj.nameStr = av.ControllingClient.Name;
1905 detobj.keyUUID = av.UUID; 1908 detobj.ownerUUID = av.UUID;
1906 detobj.nameStr = av.ControllingClient.Name; 1909 detobj.posVector = av.AbsolutePosition;
1907 detobj.ownerUUID = av.UUID; 1910 detobj.rotQuat = av.Rotation;
1908 detobj.posVector = av.AbsolutePosition; 1911 detobj.velVector = av.Velocity;
1909 detobj.rotQuat = av.Rotation; 1912 detobj.colliderType = 0;
1910 detobj.velVector = av.Velocity; 1913 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1911 detobj.colliderType = 0; 1914 colliding.Add(detobj);
1912 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1913 colliding.Add(detobj);
1914 }
1915 } 1915 }
1916 } 1916 }
1917 } 1917 }
@@ -1965,26 +1965,25 @@ if (m_shape != null) {
1965 } 1965 }
1966 else 1966 else
1967 { 1967 {
1968 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 1968 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
1969 if (avlist != null) 1969
1970 for (int i = 0; i < avlist.Length; i++)
1970 { 1971 {
1971 foreach (ScenePresence av in avlist) 1972 ScenePresence av = avlist[i];
1973
1974 if (av.LocalId == localId)
1972 { 1975 {
1973 if (av.LocalId == localId) 1976 DetectedObject detobj = new DetectedObject();
1974 { 1977 detobj.keyUUID = av.UUID;
1975 DetectedObject detobj = new DetectedObject(); 1978 detobj.nameStr = av.Name;
1976 detobj.keyUUID = av.UUID; 1979 detobj.ownerUUID = av.UUID;
1977 detobj.nameStr = av.Name; 1980 detobj.posVector = av.AbsolutePosition;
1978 detobj.ownerUUID = av.UUID; 1981 detobj.rotQuat = av.Rotation;
1979 detobj.posVector = av.AbsolutePosition; 1982 detobj.velVector = av.Velocity;
1980 detobj.rotQuat = av.Rotation; 1983 detobj.colliderType = 0;
1981 detobj.velVector = av.Velocity; 1984 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1982 detobj.colliderType = 0; 1985 colliding.Add(detobj);
1983 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1984 colliding.Add(detobj);
1985 }
1986 } 1986 }
1987
1988 } 1987 }
1989 } 1988 }
1990 } 1989 }
@@ -2035,24 +2034,24 @@ if (m_shape != null) {
2035 } 2034 }
2036 else 2035 else
2037 { 2036 {
2038 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 2037 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
2039 if (avlist != null) 2038
2039 for (int i = 0; i < avlist.Length; i++)
2040 { 2040 {
2041 foreach (ScenePresence av in avlist) 2041 ScenePresence av = avlist[i];
2042
2043 if (av.LocalId == localId)
2042 { 2044 {
2043 if (av.LocalId == localId) 2045 DetectedObject detobj = new DetectedObject();
2044 { 2046 detobj.keyUUID = av.UUID;
2045 DetectedObject detobj = new DetectedObject(); 2047 detobj.nameStr = av.Name;
2046 detobj.keyUUID = av.UUID; 2048 detobj.ownerUUID = av.UUID;
2047 detobj.nameStr = av.Name; 2049 detobj.posVector = av.AbsolutePosition;
2048 detobj.ownerUUID = av.UUID; 2050 detobj.rotQuat = av.Rotation;
2049 detobj.posVector = av.AbsolutePosition; 2051 detobj.velVector = av.Velocity;
2050 detobj.rotQuat = av.Rotation; 2052 detobj.colliderType = 0;
2051 detobj.velVector = av.Velocity; 2053 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
2052 detobj.colliderType = 0; 2054 colliding.Add(detobj);
2053 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
2054 colliding.Add(detobj);
2055 }
2056 } 2055 }
2057 } 2056 }
2058 } 2057 }
@@ -2312,8 +2311,8 @@ if (m_shape != null) {
2312 /// </summary> 2311 /// </summary>
2313 public void SendFullUpdateToAllClients() 2312 public void SendFullUpdateToAllClients()
2314 { 2313 {
2315 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2314 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2316 for (int i = 0; i < avatars.Count; i++) 2315 for (int i = 0; i < avatars.Length; i++)
2317 { 2316 {
2318 // Ugly reference :( 2317 // Ugly reference :(
2319 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2318 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
@@ -2323,8 +2322,8 @@ if (m_shape != null) {
2323 2322
2324 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2323 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2325 { 2324 {
2326 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2325 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2327 for (int i = 0; i < avatars.Count; i++) 2326 for (int i = 0; i < avatars.Length; i++)
2328 { 2327 {
2329 // Ugly reference :( 2328 // Ugly reference :(
2330 if (avatars[i].UUID != agentID) 2329 if (avatars[i].UUID != agentID)
@@ -2467,8 +2466,8 @@ if (m_shape != null) {
2467 /// </summary> 2466 /// </summary>
2468 public void SendTerseUpdateToAllClients() 2467 public void SendTerseUpdateToAllClients()
2469 { 2468 {
2470 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2469 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2471 for (int i = 0; i < avatars.Count; i++) 2470 for (int i = 0; i < avatars.Length; i++)
2472 { 2471 {
2473 SendTerseUpdateToClient(avatars[i].ControllingClient); 2472 SendTerseUpdateToClient(avatars[i].ControllingClient);
2474 } 2473 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ccfffe7..77706ac 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -869,14 +869,16 @@ namespace OpenSim.Region.Framework.Scenes
869 869
870 m_isChildAgent = false; 870 m_isChildAgent = false;
871 871
872 List<ScenePresence> AnimAgents = m_scene.GetScenePresences(); 872 ScenePresence[] animAgents = m_scene.GetScenePresences();
873 foreach (ScenePresence p in AnimAgents) 873 for (int i = 0; i < animAgents.Length; i++)
874 { 874 {
875 if (p != this) 875 ScenePresence presence = animAgents[i];
876 p.SendAnimPackToClient(ControllingClient); 876
877 if (presence != this)
878 presence.SendAnimPackToClient(ControllingClient);
877 } 879 }
878 m_scene.EventManager.TriggerOnMakeRootAgent(this);
879 880
881 m_scene.EventManager.TriggerOnMakeRootAgent(this);
880 } 882 }
881 883
882 /// <summary> 884 /// <summary>
@@ -2533,9 +2535,12 @@ namespace OpenSim.Region.Framework.Scenes
2533 { 2535 {
2534 m_perfMonMS = Environment.TickCount; 2536 m_perfMonMS = Environment.TickCount;
2535 2537
2536 List<ScenePresence> avatars = m_scene.GetScenePresences(); 2538 ScenePresence[] avatars = m_scene.GetScenePresences();
2537 foreach (ScenePresence avatar in avatars) 2539
2540 for (int i = 0; i < avatars.Length; i++)
2538 { 2541 {
2542 ScenePresence avatar = avatars[i];
2543
2539 // only send if this is the root (children are only "listening posts" in a foreign region) 2544 // only send if this is the root (children are only "listening posts" in a foreign region)
2540 if (!IsChildAgent) 2545 if (!IsChildAgent)
2541 { 2546 {
@@ -2553,7 +2558,7 @@ namespace OpenSim.Region.Framework.Scenes
2553 } 2558 }
2554 } 2559 }
2555 2560
2556 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2561 m_scene.StatsReporter.AddAgentUpdates(avatars.Length);
2557 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2562 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2558 2563
2559 //SendAnimPack(); 2564 //SendAnimPack();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 669189d..56d4d28 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7227,13 +7227,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7227 public LSL_Integer llGetNumberOfPrims() 7227 public LSL_Integer llGetNumberOfPrims()
7228 { 7228 {
7229 m_host.AddScriptLPS(1); 7229 m_host.AddScriptLPS(1);
7230 List<ScenePresence> presences = World.GetScenePresences(); 7230 ScenePresence[] presences = World.GetScenePresences();
7231 if (presences.Count == 0) 7231 if (presences.Length == 0)
7232 return 0; 7232 return 0;
7233 7233
7234 int avatarCount = 0; 7234 int avatarCount = 0;
7235 foreach (ScenePresence presence in presences) 7235 for (int i = 0; i < presences.Length; i++)
7236 { 7236 {
7237 ScenePresence presence = presences[i];
7238
7237 if (!presence.IsChildAgent && presence.ParentID != 0) 7239 if (!presence.IsChildAgent && presence.ParentID != 0)
7238 { 7240 {
7239 if (m_host.ParentGroup.HasChildPrim(presence.ParentID)) 7241 if (m_host.ParentGroup.HasChildPrim(presence.ParentID))
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index a09c8db..ee01c3c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -404,7 +404,7 @@ 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; 407 List<ScenePresence> presences;
408 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 408 List<SensedEntity> sensedEntities = new List<SensedEntity>();
409 409
410 // If this is an avatar sense by key try to get them directly 410 // If this is an avatar sense by key try to get them directly
@@ -414,16 +414,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID); 414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID);
415 if (p == null) 415 if (p == null)
416 return sensedEntities; 416 return sensedEntities;
417 Presences = new List<ScenePresence>(); 417 presences = new List<ScenePresence>();
418 Presences.Add(p); 418 presences.Add(p);
419 } 419 }
420 else 420 else
421 { 421 {
422 Presences = m_CmdManager.m_ScriptEngine.World.GetScenePresences(); 422 presences = new List<ScenePresence>(m_CmdManager.m_ScriptEngine.World.GetScenePresences());
423 } 423 }
424 424
425 // If nobody about quit fast 425 // If nobody about quit fast
426 if (Presences.Count == 0) 426 if (presences.Count == 0)
427 return sensedEntities; 427 return sensedEntities;
428 428
429 SceneObjectPart SensePoint = ts.host; 429 SceneObjectPart SensePoint = ts.host;
@@ -440,8 +440,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
440 Vector3 toRegionPos; 440 Vector3 toRegionPos;
441 double dis; 441 double dis;
442 442
443 foreach (ScenePresence presence in Presences) 443 for (int i = 0; i < presences.Count; i++)
444 { 444 {
445 ScenePresence presence = presences[i];
445 bool keep = true; 446 bool keep = true;
446 447
447 if (presence.IsDeleted) 448 if (presence.IsDeleted)
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
index d7c39a3..704b74f 100644
--- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
+++ b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
@@ -68,11 +68,11 @@ 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(); 71 ScenePresence[] avatarInScene = scene.GetScenePresences();
72 72
73 HTMLUtil.LI_O(ref output, ""); 73 HTMLUtil.LI_O(ref output, String.Empty);
74 output.Append(scene.RegionInfo.RegionName); 74 output.Append(scene.RegionInfo.RegionName);
75 HTMLUtil.OL_O(ref output, ""); 75 HTMLUtil.OL_O(ref output, String.Empty);
76 foreach (ScenePresence av in avatarInScene) 76 foreach (ScenePresence av in avatarInScene)
77 { 77 {
78 Dictionary<string,string> queues = new Dictionary<string, string>(); 78 Dictionary<string,string> queues = new Dictionary<string, string>();
@@ -81,7 +81,7 @@ namespace OpenSim.Region.UserStatistics
81 IStatsCollector isClient = (IStatsCollector) av.ControllingClient; 81 IStatsCollector isClient = (IStatsCollector) av.ControllingClient;
82 queues = decodeQueueReport(isClient.Report()); 82 queues = decodeQueueReport(isClient.Report());
83 } 83 }
84 HTMLUtil.LI_O(ref output, ""); 84 HTMLUtil.LI_O(ref output, String.Empty);
85 output.Append(av.Name); 85 output.Append(av.Name);
86 output.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"); 86 output.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
87 output.Append((av.IsChildAgent ? "Child" : "Root")); 87 output.Append((av.IsChildAgent ? "Child" : "Root"));
@@ -96,12 +96,12 @@ namespace OpenSim.Region.UserStatistics
96 (int) av.AbsolutePosition.Z)); 96 (int) av.AbsolutePosition.Z));
97 } 97 }
98 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1)); 98 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
99 99
100 HTMLUtil.UL_O(ref output, ""); 100 HTMLUtil.UL_O(ref output, String.Empty);
101 101
102 foreach (string throttlename in throttles.Keys) 102 foreach (string throttlename in throttles.Keys)
103 { 103 {
104 HTMLUtil.LI_O(ref output, ""); 104 HTMLUtil.LI_O(ref output, String.Empty);
105 output.Append(throttlename); 105 output.Append(throttlename);
106 output.Append(":"); 106 output.Append(":");
107 output.Append(throttles[throttlename].ToString()); 107 output.Append(throttles[throttlename].ToString());