aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs29
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs69
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs193
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs82
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs22
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs48
10 files changed, 246 insertions, 229 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 6ebd048..cadb858 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1522,9 +1522,10 @@ namespace OpenSim.Region.Framework.Scenes
1522 if (remoteClient != null) 1522 if (remoteClient != null)
1523 { 1523 {
1524 permissionToTake = 1524 permissionToTake =
1525 Permissions.CanReturnObject( 1525 Permissions.CanReturnObjects(
1526 grp.UUID, 1526 null,
1527 remoteClient.AgentId); 1527 remoteClient.AgentId,
1528 new List<SceneObjectGroup>() {grp});
1528 permissionToDelete = permissionToTake; 1529 permissionToDelete = permissionToTake;
1529 1530
1530 if (permissionToDelete) 1531 if (permissionToDelete)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index d1d6b6a..7dab04f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes
48 public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); 48 public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
49 public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); 49 public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene);
50 public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); 50 public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
51 public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene); 51 public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene);
52 public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); 52 public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene);
53 public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); 53 public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene);
54 public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); 54 public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
@@ -81,7 +81,6 @@ namespace OpenSim.Region.Framework.Scenes
81 public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID); 81 public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID);
82 public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); 82 public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID);
83 public delegate bool TeleportHandler(UUID userID, Scene scene); 83 public delegate bool TeleportHandler(UUID userID, Scene scene);
84 public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene);
85 #endregion 84 #endregion
86 85
87 public class ScenePermissions 86 public class ScenePermissions
@@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
107 public event EditObjectInventoryHandler OnEditObjectInventory; 106 public event EditObjectInventoryHandler OnEditObjectInventory;
108 public event MoveObjectHandler OnMoveObject; 107 public event MoveObjectHandler OnMoveObject;
109 public event ObjectEntryHandler OnObjectEntry; 108 public event ObjectEntryHandler OnObjectEntry;
110 public event ReturnObjectHandler OnReturnObject; 109 public event ReturnObjectsHandler OnReturnObjects;
111 public event InstantMessageHandler OnInstantMessage; 110 public event InstantMessageHandler OnInstantMessage;
112 public event InventoryTransferHandler OnInventoryTransfer; 111 public event InventoryTransferHandler OnInventoryTransfer;
113 public event ViewScriptHandler OnViewScript; 112 public event ViewScriptHandler OnViewScript;
@@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes
140 public event CopyUserInventoryHandler OnCopyUserInventory; 139 public event CopyUserInventoryHandler OnCopyUserInventory;
141 public event DeleteUserInventoryHandler OnDeleteUserInventory; 140 public event DeleteUserInventoryHandler OnDeleteUserInventory;
142 public event TeleportHandler OnTeleport; 141 public event TeleportHandler OnTeleport;
143 public event UseObjectReturnHandler OnUseObjectReturn;
144 #endregion 142 #endregion
145 143
146 #region Object Permission Checks 144 #region Object Permission Checks
@@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes
377 #endregion 375 #endregion
378 376
379 #region RETURN OBJECT 377 #region RETURN OBJECT
380 public bool CanReturnObject(UUID objectID, UUID returnerID) 378 public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects)
381 { 379 {
382 ReturnObjectHandler handler = OnReturnObject; 380 ReturnObjectsHandler handler = OnReturnObjects;
383 if (handler != null) 381 if (handler != null)
384 { 382 {
385 Delegate[] list = handler.GetInvocationList(); 383 Delegate[] list = handler.GetInvocationList();
386 foreach (ReturnObjectHandler h in list) 384 foreach (ReturnObjectsHandler h in list)
387 { 385 {
388 if (h(objectID, returnerID, m_scene) == false) 386 if (h(land, user, objects, m_scene) == false)
389 return false; 387 return false;
390 } 388 }
391 } 389 }
@@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes
949 } 947 }
950 return true; 948 return true;
951 } 949 }
952
953 public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List<SceneObjectGroup> retlist)
954 {
955 UseObjectReturnHandler handler = OnUseObjectReturn;
956 if (handler != null)
957 {
958 Delegate[] list = handler.GetInvocationList();
959 foreach (UseObjectReturnHandler h in list)
960 {
961 if (h(landData, type, client, retlist, m_scene) == false)
962 return false;
963 }
964 }
965 return true;
966 }
967 } 950 }
968} 951}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 03f1ee2..b2c8dfd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -131,7 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
131 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 131 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
132 private int m_incrementsof15seconds; 132 private int m_incrementsof15seconds;
133 private volatile bool m_backingup; 133 private volatile bool m_backingup;
134 private bool m_useAsyncWhenPossible;
135 134
136 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 135 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
137 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); 136 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
@@ -656,9 +655,6 @@ namespace OpenSim.Region.Framework.Scenes
656 // 655 //
657 IConfig startupConfig = m_config.Configs["Startup"]; 656 IConfig startupConfig = m_config.Configs["Startup"];
658 657
659 // Should we try to run loops synchronously or asynchronously?
660 m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false);
661
662 //Animation states 658 //Animation states
663 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 659 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
664 // TODO: Change default to true once the feature is supported 660 // TODO: Change default to true once the feature is supported
@@ -3636,9 +3632,7 @@ namespace OpenSim.Region.Framework.Scenes
3636 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3632 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3637 { 3633 {
3638 ScenePresence presence; 3634 ScenePresence presence;
3639 m_sceneGraph.TryGetAvatar(agentID, out presence); 3635 if(m_sceneGraph.TryGetAvatar(agentID, out presence))
3640
3641 if (presence != null)
3642 { 3636 {
3643 try 3637 try
3644 { 3638 {
@@ -3813,9 +3807,7 @@ namespace OpenSim.Region.Framework.Scenes
3813 Vector3 lookAt, uint teleportFlags) 3807 Vector3 lookAt, uint teleportFlags)
3814 { 3808 {
3815 ScenePresence sp; 3809 ScenePresence sp;
3816 m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp); 3810 if(m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp))
3817
3818 if (sp != null)
3819 { 3811 {
3820 uint regionX = m_regInfo.RegionLocX; 3812 uint regionX = m_regInfo.RegionLocX;
3821 uint regionY = m_regInfo.RegionLocY; 3813 uint regionY = m_regInfo.RegionLocY;
@@ -4171,6 +4163,11 @@ namespace OpenSim.Region.Framework.Scenes
4171 4163
4172 //The idea is to have a group of method that return a list of avatars meeting some requirement 4164 //The idea is to have a group of method that return a list of avatars meeting some requirement
4173 // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. 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.
4174 4171
4175 /// <summary> 4172 /// <summary>
4176 /// Return a list of all avatars in this region. 4173 /// Return a list of all avatars in this region.
@@ -4187,7 +4184,7 @@ namespace OpenSim.Region.Framework.Scenes
4187 /// This list is a new object, so it can be iterated over without locking. 4184 /// This list is a new object, so it can be iterated over without locking.
4188 /// </summary> 4185 /// </summary>
4189 /// <returns></returns> 4186 /// <returns></returns>
4190 public ScenePresence[] GetScenePresences() 4187 public List<ScenePresence> GetScenePresences()
4191 { 4188 {
4192 return m_sceneGraph.GetScenePresences(); 4189 return m_sceneGraph.GetScenePresences();
4193 } 4190 }
@@ -4213,6 +4210,28 @@ namespace OpenSim.Region.Framework.Scenes
4213 return m_sceneGraph.GetScenePresence(avatarID); 4210 return m_sceneGraph.GetScenePresence(avatarID);
4214 } 4211 }
4215 4212
4213 /// <summary>
4214 /// Request the ScenePresence in this region by first/last name.
4215 /// Should normally only be a single match, but first is always returned
4216 /// </summary>
4217 /// <param name="firstName"></param>
4218 /// <param name="lastName"></param>
4219 /// <returns></returns>
4220 public ScenePresence GetScenePresence(string firstName, string lastName)
4221 {
4222 return m_sceneGraph.GetScenePresence(firstName, lastName);
4223 }
4224
4225 /// <summary>
4226 /// Request the ScenePresence in this region by localID.
4227 /// </summary>
4228 /// <param name="localID"></param>
4229 /// <returns></returns>
4230 public ScenePresence GetScenePresence(uint localID)
4231 {
4232 return m_sceneGraph.GetScenePresence(localID);
4233 }
4234
4216 public override bool PresenceChildStatus(UUID avatarID) 4235 public override bool PresenceChildStatus(UUID avatarID)
4217 { 4236 {
4218 ScenePresence cp = GetScenePresence(avatarID); 4237 ScenePresence cp = GetScenePresence(avatarID);
@@ -4228,25 +4247,14 @@ namespace OpenSim.Region.Framework.Scenes
4228 } 4247 }
4229 4248
4230 /// <summary> 4249 /// <summary>
4231 /// 4250 /// Performs action on all scene presences.
4232 /// </summary> 4251 /// </summary>
4233 /// <param name="action"></param> 4252 /// <param name="action"></param>
4234 public void ForEachScenePresence(Action<ScenePresence> action) 4253 public void ForEachScenePresence(Action<ScenePresence> action)
4235 { 4254 {
4236 // We don't want to try to send messages if there are no avatars.
4237 if (m_sceneGraph != null) 4255 if (m_sceneGraph != null)
4238 { 4256 {
4239 try 4257 m_sceneGraph.ForEachScenePresence(action);
4240 {
4241 ScenePresence[] presences = GetScenePresences();
4242 for (int i = 0; i < presences.Length; i++)
4243 action(presences[i]);
4244 }
4245 catch (Exception e)
4246 {
4247 m_log.Info("[BUG] in " + RegionInfo.RegionName + ": " + e.ToString());
4248 m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
4249 }
4250 } 4258 }
4251 } 4259 }
4252 4260
@@ -4322,20 +4330,7 @@ namespace OpenSim.Region.Framework.Scenes
4322 4330
4323 public void ForEachClient(Action<IClientAPI> action) 4331 public void ForEachClient(Action<IClientAPI> action)
4324 { 4332 {
4325 ForEachClient(action, m_useAsyncWhenPossible);
4326 }
4327
4328 public void ForEachClient(Action<IClientAPI> action, bool doAsynchronous)
4329 {
4330 // FIXME: Asynchronous iteration is disabled until we have a threading model that
4331 // can support calling this function from an async packet handler without
4332 // potentially deadlocking
4333 m_clientManager.ForEachSync(action); 4333 m_clientManager.ForEachSync(action);
4334
4335 //if (doAsynchronous)
4336 // m_clientManager.ForEach(action);
4337 //else
4338 // m_clientManager.ForEachSync(action);
4339 } 4334 }
4340 4335
4341 public bool TryGetClient(UUID avatarID, out IClientAPI client) 4336 public bool TryGetClient(UUID avatarID, out IClientAPI client)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index db70d6a..19298d2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -165,9 +165,10 @@ namespace OpenSim.Region.Framework.Scenes
165 165
166 protected internal void UpdatePresences() 166 protected internal void UpdatePresences()
167 { 167 {
168 ScenePresence[] updateScenePresences = GetScenePresences(); 168 ForEachScenePresence(delegate(ScenePresence presence)
169 for (int i = 0; i < updateScenePresences.Length; i++) 169 {
170 updateScenePresences[i].Update(); 170 presence.Update();
171 });
171 } 172 }
172 173
173 protected internal float UpdatePhysics(double elapsed) 174 protected internal float UpdatePhysics(double elapsed)
@@ -196,9 +197,10 @@ namespace OpenSim.Region.Framework.Scenes
196 197
197 protected internal void UpdateScenePresenceMovement() 198 protected internal void UpdateScenePresenceMovement()
198 { 199 {
199 ScenePresence[] moveEntities = GetScenePresences(); 200 ForEachScenePresence(delegate(ScenePresence presence)
200 for (int i = 0; i < moveEntities.Length; i++) 201 {
201 moveEntities[i].UpdateMovement(); 202 presence.UpdateMovement();
203 });
202 } 204 }
203 205
204 #endregion 206 #endregion
@@ -640,18 +642,16 @@ namespace OpenSim.Region.Framework.Scenes
640 642
641 public void RecalculateStats() 643 public void RecalculateStats()
642 { 644 {
643 ScenePresence[] presences = GetScenePresences();
644 int rootcount = 0; 645 int rootcount = 0;
645 int childcount = 0; 646 int childcount = 0;
646 647
647 for (int i = 0; i < presences.Length; i++) 648 ForEachScenePresence(delegate(ScenePresence presence)
648 { 649 {
649 ScenePresence user = presences[i]; 650 if (presence.IsChildAgent)
650 if (user.IsChildAgent)
651 ++childcount; 651 ++childcount;
652 else 652 else
653 ++rootcount; 653 ++rootcount;
654 } 654 });
655 655
656 m_numRootAgents = rootcount; 656 m_numRootAgents = rootcount;
657 m_numChildAgents = childcount; 657 m_numChildAgents = childcount;
@@ -698,25 +698,6 @@ namespace OpenSim.Region.Framework.Scenes
698 #endregion 698 #endregion
699 699
700 #region Get Methods 700 #region Get Methods
701
702 /// <summary>
703 /// Request a List of all scene presences in this scene. This is a new list, so no
704 /// locking is required to iterate over it.
705 /// </summary>
706 /// <returns></returns>
707 protected internal ScenePresence[] GetScenePresences()
708 {
709 return m_scenePresenceArray;
710 }
711
712 protected internal List<ScenePresence> GetAvatars()
713 {
714 List<ScenePresence> result =
715 GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; });
716
717 return result;
718 }
719
720 /// <summary> 701 /// <summary>
721 /// Get the controlling client for the given avatar, if there is one. 702 /// Get the controlling client for the given avatar, if there is one.
722 /// 703 ///
@@ -742,45 +723,119 @@ namespace OpenSim.Region.Framework.Scenes
742 return null; 723 return null;
743 } 724 }
744 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>
735 /// Request a list of all avatars in this region (no child agents)
736 /// This list is a new object, so it can be iterated over without locking.
737 /// </summary>
738 /// <returns></returns>
739 public List<ScenePresence> GetAvatars()
740 {
741 return GetScenePresences(delegate(ScenePresence scenePresence)
742 {
743 return !scenePresence.IsChildAgent;
744 });
745 }
746
747 /// <summary>
748 /// Request a list of m_scenePresences in this World
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>
752 /// <returns></returns>
753 protected internal List<ScenePresence> GetScenePresences()
754 {
755 List<ScenePresence> result;
756 lock (m_scenePresences)
757 {
758 result = new List<ScenePresence>(m_scenePresenceArray.Length);
759 result.AddRange(m_scenePresenceArray);
760 }
761 return result;
762 }
763
745 /// <summary> 764 /// <summary>
746 /// Request a filtered list of m_scenePresences in this World 765 /// Request a filtered list of m_scenePresences in this World
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.
747 /// </summary> 768 /// </summary>
748 /// <returns></returns> 769 /// <returns></returns>
749 protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter) 770 protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter)
750 { 771 {
751 // No locking of scene presences here since we're passing back a list...
752
753 List<ScenePresence> result = new List<ScenePresence>(); 772 List<ScenePresence> result = new List<ScenePresence>();
754 ScenePresence[] scenePresences = GetScenePresences(); 773 // Check each ScenePresence against the filter
774 ForEachScenePresence(delegate(ScenePresence presence)
775 {
776 if (filter(presence))
777 result.Add(presence);
778 });
779 return result;
780 }
755 781
756 for (int i = 0; i < scenePresences.Length; i++) 782 /// <summary>
783 /// Request the ScenePresence in this region matching filter.
784 /// Only the first match is returned.
785 ///
786 /// </summary>
787 /// <param name="filter"></param>
788 /// <returns></returns>
789 protected internal ScenePresence GetScenePresence(FilterAvatarList filter)
790 {
791 ScenePresence result = null;
792 // Get all of the ScenePresences
793 List<ScenePresence> presences = GetScenePresences();
794 foreach (ScenePresence presence in presences)
757 { 795 {
758 ScenePresence avatar = scenePresences[i]; 796 if (filter(presence))
759 if (filter(avatar)) 797 {
760 result.Add(avatar); 798 result = presence;
799 break;
800 }
761 } 801 }
762
763 return result; 802 return result;
764 } 803 }
765 804
805 protected internal ScenePresence GetScenePresence(string firstName, string lastName)
806 {
807 return GetScenePresence(delegate(ScenePresence presence)
808 {
809 return(presence.Firstname == firstName && presence.Lastname == lastName);
810 });
811 }
812
766 /// <summary> 813 /// <summary>
767 /// Request a scene presence by UUID 814 /// Request a scene presence by UUID
768 /// </summary> 815 /// </summary>
769 /// <param name="avatarID"></param> 816 /// <param name="agentID"></param>
770 /// <returns>null if the agent was not found</returns> 817 /// <returns>null if the agent was not found</returns>
771 protected internal ScenePresence GetScenePresence(UUID agentID) 818 protected internal ScenePresence GetScenePresence(UUID agentID)
772 { 819 {
773 ScenePresence sp; 820 ScenePresence sp;
774 821 TryGetAvatar(agentID, out sp);
775 lock (m_scenePresences)
776 {
777 m_scenePresences.TryGetValue(agentID, out sp);
778 }
779
780 return sp; 822 return sp;
781 } 823 }
782 824
783 /// <summary> 825 /// <summary>
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 {
832 return GetScenePresence(delegate(ScenePresence presence)
833 {
834 return (presence.LocalId == localID);
835 });
836 }
837
838 /// <summary>
784 /// Get a scene object group that contains the prim with the given local id 839 /// Get a scene object group that contains the prim with the given local id
785 /// </summary> 840 /// </summary>
786 /// <param name="localID"></param> 841 /// <param name="localID"></param>
@@ -934,29 +989,19 @@ namespace OpenSim.Region.Framework.Scenes
934 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 989 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
935 { 990 {
936 lock (m_scenePresences) 991 lock (m_scenePresences)
937 return m_scenePresences.TryGetValue(avatarId, out avatar); 992 {
993 m_scenePresences.TryGetValue(avatarId, out avatar);
994 }
995 return (avatar != null);
938 } 996 }
939 997
940 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 998 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
941 { 999 {
942 ScenePresence[] presences = GetScenePresences(); 1000 avatar = GetScenePresence(delegate(ScenePresence presence)
943
944 for (int i = 0; i < presences.Length; i++)
945 { 1001 {
946 ScenePresence presence = presences[i]; 1002 return (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0);
947 1003 });
948 if (!presence.IsChildAgent) 1004 return (avatar != null);
949 {
950 if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0)
951 {
952 avatar = presence;
953 return true;
954 }
955 }
956 }
957
958 avatar = null;
959 return false;
960 } 1005 }
961 1006
962 /// <summary> 1007 /// <summary>
@@ -1037,6 +1082,28 @@ namespace OpenSim.Region.Framework.Scenes
1037 } 1082 }
1038 } 1083 }
1039 } 1084 }
1085
1086
1087 /// <summary>
1088 /// Performs action on all scene presences.
1089 /// </summary>
1090 /// <param name="action"></param>
1091 public void ForEachScenePresence(Action<ScenePresence> action)
1092 {
1093 List<ScenePresence> presences = GetScenePresences();
1094 try
1095 {
1096 foreach(ScenePresence presence in presences)
1097 {
1098 action(presence);
1099 }
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 }
1106 }
1040 1107
1041 #endregion 1108 #endregion
1042 1109
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 680c39a..a955532 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -414,12 +414,8 @@ namespace OpenSim.Region.Framework.Scenes
414 ForEachCurrentScene( 414 ForEachCurrentScene(
415 delegate(Scene scene) 415 delegate(Scene scene)
416 { 416 {
417 ScenePresence[] scenePresences = scene.GetScenePresences(); 417 scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
418
419 for (int i = 0; i < scenePresences.Length; i++)
420 { 418 {
421 ScenePresence scenePresence = scenePresences[i];
422
423 if (!scenePresence.IsChildAgent) 419 if (!scenePresence.IsChildAgent)
424 { 420 {
425 m_log.DebugFormat("Packet debug for {0} {1} set to {2}", 421 m_log.DebugFormat("Packet debug for {0} {1} set to {2}",
@@ -429,7 +425,7 @@ namespace OpenSim.Region.Framework.Scenes
429 425
430 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); 426 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
431 } 427 }
432 } 428 });
433 } 429 }
434 ); 430 );
435 } 431 }
@@ -441,14 +437,11 @@ namespace OpenSim.Region.Framework.Scenes
441 ForEachCurrentScene( 437 ForEachCurrentScene(
442 delegate(Scene scene) 438 delegate(Scene scene)
443 { 439 {
444 ScenePresence[] scenePresences = scene.GetScenePresences(); 440 scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
445
446 for (int i = 0; i < scenePresences.Length; i++)
447 { 441 {
448 ScenePresence scenePresence = scenePresences[i];
449 if (!scenePresence.IsChildAgent) 442 if (!scenePresence.IsChildAgent)
450 avatars.Add(scenePresence); 443 avatars.Add(scenePresence);
451 } 444 });
452 } 445 }
453 ); 446 );
454 447
@@ -461,7 +454,7 @@ namespace OpenSim.Region.Framework.Scenes
461 454
462 ForEachCurrentScene(delegate(Scene scene) 455 ForEachCurrentScene(delegate(Scene scene)
463 { 456 {
464 ScenePresence[] scenePresences = scene.GetScenePresences(); 457 List<ScenePresence> scenePresences = scene.GetScenePresences();
465 presences.AddRange(scenePresences); 458 presences.AddRange(scenePresences);
466 }); 459 });
467 460
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index d083119..3895d93 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1370,8 +1370,8 @@ namespace OpenSim.Region.Framework.Scenes
1370 { 1370 {
1371// part.Inventory.RemoveScriptInstances(); 1371// part.Inventory.RemoveScriptInstances();
1372 1372
1373 ScenePresence[] avatars = Scene.GetScenePresences(); 1373 List<ScenePresence> avatars = Scene.GetScenePresences();
1374 for (int i = 0; i < avatars.Length; i++) 1374 for (int i = 0; i < avatars.Count; i++)
1375 { 1375 {
1376 if (avatars[i].ParentID == LocalId) 1376 if (avatars[i].ParentID == LocalId)
1377 { 1377 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 48e34ee..539f2b1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1208,15 +1208,14 @@ namespace OpenSim.Region.Framework.Scenes
1208 1208
1209 private void SendObjectPropertiesToClient(UUID AgentID) 1209 private void SendObjectPropertiesToClient(UUID AgentID)
1210 { 1210 {
1211 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1211 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1212 for (int i = 0; i < avatars.Length; i++)
1213 { 1212 {
1214 // Ugly reference :( 1213 // Ugly reference :(
1215 if (avatars[i].UUID == AgentID) 1214 if (avatar.UUID == AgentID)
1216 { 1215 {
1217 m_parentGroup.GetProperties(avatars[i].ControllingClient); 1216 m_parentGroup.GetProperties(avatar.ControllingClient);
1218 } 1217 }
1219 } 1218 });
1220 } 1219 }
1221 1220
1222 // TODO: unused: 1221 // TODO: unused:
@@ -1271,11 +1270,10 @@ namespace OpenSim.Region.Framework.Scenes
1271 /// </summary> 1270 /// </summary>
1272 public void AddFullUpdateToAllAvatars() 1271 public void AddFullUpdateToAllAvatars()
1273 { 1272 {
1274 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1273 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1275 for (int i = 0; i < avatars.Length; i++)
1276 { 1274 {
1277 avatars[i].SceneViewer.QueuePartForUpdate(this); 1275 avatar.SceneViewer.QueuePartForUpdate(this);
1278 } 1276 });
1279 } 1277 }
1280 1278
1281 public void AddFullUpdateToAvatar(ScenePresence presence) 1279 public void AddFullUpdateToAvatar(ScenePresence presence)
@@ -1296,11 +1294,10 @@ namespace OpenSim.Region.Framework.Scenes
1296 /// Terse updates 1294 /// Terse updates
1297 public void AddTerseUpdateToAllAvatars() 1295 public void AddTerseUpdateToAllAvatars()
1298 { 1296 {
1299 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1297 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1300 for (int i = 0; i < avatars.Length; i++)
1301 { 1298 {
1302 avatars[i].SceneViewer.QueuePartForUpdate(this); 1299 avatar.SceneViewer.QueuePartForUpdate(this);
1303 } 1300 });
1304 } 1301 }
1305 1302
1306 public void AddTerseUpdateToAvatar(ScenePresence presence) 1303 public void AddTerseUpdateToAvatar(ScenePresence presence)
@@ -2137,17 +2134,13 @@ namespace OpenSim.Region.Framework.Scenes
2137 } 2134 }
2138 else 2135 else
2139 { 2136 {
2140 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2137 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2141
2142 for (int i = 0; i < avlist.Length; i++)
2143 { 2138 {
2144 ScenePresence av = avlist[i];
2145
2146 if (av.LocalId == localId) 2139 if (av.LocalId == localId)
2147 { 2140 {
2148 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2141 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2149 { 2142 {
2150 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2143 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2151 //If it is 1, it is to accept ONLY collisions from this avatar 2144 //If it is 1, it is to accept ONLY collisions from this avatar
2152 if (found) 2145 if (found)
2153 { 2146 {
@@ -2169,7 +2162,7 @@ namespace OpenSim.Region.Framework.Scenes
2169 } 2162 }
2170 else 2163 else
2171 { 2164 {
2172 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2165 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2173 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2166 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2174 if (!found) 2167 if (!found)
2175 { 2168 {
@@ -2187,7 +2180,7 @@ namespace OpenSim.Region.Framework.Scenes
2187 } 2180 }
2188 2181
2189 } 2182 }
2190 } 2183 });
2191 } 2184 }
2192 } 2185 }
2193 if (colliding.Count > 0) 2186 if (colliding.Count > 0)
@@ -2273,17 +2266,13 @@ namespace OpenSim.Region.Framework.Scenes
2273 } 2266 }
2274 else 2267 else
2275 { 2268 {
2276 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2269 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2277
2278 for (int i = 0; i < avlist.Length; i++)
2279 { 2270 {
2280 ScenePresence av = avlist[i];
2281
2282 if (av.LocalId == localId) 2271 if (av.LocalId == localId)
2283 { 2272 {
2284 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2273 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2285 { 2274 {
2286 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2275 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2287 //If it is 1, it is to accept ONLY collisions from this avatar 2276 //If it is 1, it is to accept ONLY collisions from this avatar
2288 if (found) 2277 if (found)
2289 { 2278 {
@@ -2305,7 +2294,7 @@ namespace OpenSim.Region.Framework.Scenes
2305 } 2294 }
2306 else 2295 else
2307 { 2296 {
2308 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2297 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2309 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2298 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2310 if (!found) 2299 if (!found)
2311 { 2300 {
@@ -2323,7 +2312,7 @@ namespace OpenSim.Region.Framework.Scenes
2323 } 2312 }
2324 2313
2325 } 2314 }
2326 } 2315 });
2327 } 2316 }
2328 } 2317 }
2329 if (colliding.Count > 0) 2318 if (colliding.Count > 0)
@@ -2404,17 +2393,13 @@ namespace OpenSim.Region.Framework.Scenes
2404 } 2393 }
2405 else 2394 else
2406 { 2395 {
2407 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); 2396 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
2408
2409 for (int i = 0; i < avlist.Length; i++)
2410 { 2397 {
2411 ScenePresence av = avlist[i];
2412
2413 if (av.LocalId == localId) 2398 if (av.LocalId == localId)
2414 { 2399 {
2415 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 2400 if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name))
2416 { 2401 {
2417 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2402 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2418 //If it is 1, it is to accept ONLY collisions from this avatar 2403 //If it is 1, it is to accept ONLY collisions from this avatar
2419 if (found) 2404 if (found)
2420 { 2405 {
@@ -2436,7 +2421,7 @@ namespace OpenSim.Region.Framework.Scenes
2436 } 2421 }
2437 else 2422 else
2438 { 2423 {
2439 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); 2424 bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data);
2440 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work 2425 //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
2441 if (!found) 2426 if (!found)
2442 { 2427 {
@@ -2454,7 +2439,7 @@ namespace OpenSim.Region.Framework.Scenes
2454 } 2439 }
2455 2440
2456 } 2441 }
2457 } 2442 });
2458 } 2443 }
2459 } 2444 }
2460 2445
@@ -2863,11 +2848,10 @@ namespace OpenSim.Region.Framework.Scenes
2863 /// </summary> 2848 /// </summary>
2864 public void SendFullUpdateToAllClients() 2849 public void SendFullUpdateToAllClients()
2865 { 2850 {
2866 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2851 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
2867 for (int i = 0; i < avatars.Length; i++)
2868 { 2852 {
2869 SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID)); 2853 SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
2870 } 2854 });
2871 } 2855 }
2872 2856
2873 /// <summary> 2857 /// <summary>
@@ -2876,13 +2860,12 @@ namespace OpenSim.Region.Framework.Scenes
2876 /// <param name="agentID"></param> 2860 /// <param name="agentID"></param>
2877 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2861 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2878 { 2862 {
2879 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2863 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
2880 for (int i = 0; i < avatars.Length; i++)
2881 { 2864 {
2882 // Ugly reference :( 2865 // Ugly reference :(
2883 if (avatars[i].UUID != agentID) 2866 if (avatar.UUID != agentID)
2884 SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID)); 2867 SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
2885 } 2868 });
2886 } 2869 }
2887 2870
2888 /// <summary> 2871 /// <summary>
@@ -3083,11 +3066,10 @@ namespace OpenSim.Region.Framework.Scenes
3083 /// </summary> 3066 /// </summary>
3084 public void SendTerseUpdateToAllClients() 3067 public void SendTerseUpdateToAllClients()
3085 { 3068 {
3086 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 3069 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
3087 for (int i = 0; i < avatars.Length; i++)
3088 { 3070 {
3089 SendTerseUpdateToClient(avatars[i].ControllingClient); 3071 SendTerseUpdateToClient(avatar.ControllingClient);
3090 } 3072 });
3091 } 3073 }
3092 3074
3093 public void SetAttachmentPoint(uint AttachmentPoint) 3075 public void SetAttachmentPoint(uint AttachmentPoint)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 608e84c..1e530e1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -881,7 +881,7 @@ namespace OpenSim.Region.Framework.Scenes
881 if (land != null) 881 if (land != null)
882 { 882 {
883 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. 883 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
884 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) 884 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid)
885 { 885 {
886 pos = land.LandData.UserLocation; 886 pos = land.LandData.UserLocation;
887 } 887 }
@@ -959,14 +959,11 @@ namespace OpenSim.Region.Framework.Scenes
959 959
960 m_isChildAgent = false; 960 m_isChildAgent = false;
961 961
962 ScenePresence[] animAgents = m_scene.GetScenePresences(); 962 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
963 for (int i = 0; i < animAgents.Length; i++)
964 { 963 {
965 ScenePresence presence = animAgents[i];
966
967 if (presence != this) 964 if (presence != this)
968 presence.Animator.SendAnimPackToClient(ControllingClient); 965 presence.Animator.SendAnimPackToClient(ControllingClient);
969 } 966 });
970 967
971 m_scene.EventManager.TriggerOnMakeRootAgent(this); 968 m_scene.EventManager.TriggerOnMakeRootAgent(this);
972 } 969 }
@@ -2671,13 +2668,10 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2671 public void SendInitialFullUpdateToAllClients() 2668 public void SendInitialFullUpdateToAllClients()
2672 { 2669 {
2673 m_perfMonMS = Util.EnvironmentTickCount(); 2670 m_perfMonMS = Util.EnvironmentTickCount();
2674 2671 int avUpdates = 0;
2675 ScenePresence[] avatars = m_scene.GetScenePresences(); 2672 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2676
2677 for (int i = 0; i < avatars.Length; i++)
2678 { 2673 {
2679 ScenePresence avatar = avatars[i]; 2674 ++avUpdates;
2680
2681 // only send if this is the root (children are only "listening posts" in a foreign region) 2675 // only send if this is the root (children are only "listening posts" in a foreign region)
2682 if (!IsChildAgent) 2676 if (!IsChildAgent)
2683 { 2677 {
@@ -2693,9 +2687,9 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
2693 avatar.Animator.SendAnimPackToClient(ControllingClient); 2687 avatar.Animator.SendAnimPackToClient(ControllingClient);
2694 } 2688 }
2695 } 2689 }
2696 } 2690 });
2697 2691
2698 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2692 m_scene.StatsReporter.AddAgentUpdates(avUpdates);
2699 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2693 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2700 2694
2701 //Animator.SendAnimPack(); 2695 //Animator.SendAnimPack();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 6686264..8b80ebe 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero); 61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero);
62 m_assetService.Store(corruptAsset); 62 m_assetService.Store(corruptAsset);
63 63
64 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 64 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
65 m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); 65 m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids);
66 66
67 // We count the uuid as gathered even if the asset itself is corrupt. 67 // We count the uuid as gathered even if the asset itself is corrupt.
@@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
77 TestHelper.InMethod(); 77 TestHelper.InMethod();
78 78
79 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 79 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
80 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 80 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
81 81
82 m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); 82 m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids);
83 83
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 3edb677..0ec3cc3 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -84,9 +84,9 @@ namespace OpenSim.Region.Framework.Scenes
84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> 84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
85 /// <param name="assetType">The type of the asset for the uuid given</param> 85 /// <param name="assetType">The type of the asset for the uuid given</param>
86 /// <param name="assetUuids">The assets gathered</param> 86 /// <param name="assetUuids">The assets gathered</param>
87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, int> assetUuids) 87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids)
88 { 88 {
89 assetUuids[assetUuid] = 1; 89 assetUuids[assetUuid] = assetType;
90 90
91 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) 91 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
92 { 92 {
@@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes
116 /// 116 ///
117 /// <param name="sceneObject">The scene object for which to gather assets</param> 117 /// <param name="sceneObject">The scene object for which to gather assets</param>
118 /// <param name="assetUuids">The assets gathered</param> 118 /// <param name="assetUuids">The assets gathered</param>
119 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, int> assetUuids) 119 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)
120 { 120 {
121// m_log.DebugFormat( 121// m_log.DebugFormat(
122// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); 122// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
@@ -129,25 +129,26 @@ namespace OpenSim.Region.Framework.Scenes
129 try 129 try
130 { 130 {
131 Primitive.TextureEntry textureEntry = part.Shape.Textures; 131 Primitive.TextureEntry textureEntry = part.Shape.Textures;
132 132 if (textureEntry != null)
133 // Get the prim's default texture. This will be used for faces which don't have their own texture
134 assetUuids[textureEntry.DefaultTexture.TextureID] = 1;
135
136 // XXX: Not a great way to iterate through face textures, but there's no
137 // other method available to tell how many faces there actually are
138 //int i = 0;
139 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
140 { 133 {
141 if (texture != null) 134 // Get the prim's default texture. This will be used for faces which don't have their own texture
135 if (textureEntry.DefaultTexture != null)
136 assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
137
138 if (textureEntry.FaceTextures != null)
142 { 139 {
143 //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); 140 // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
144 assetUuids[texture.TextureID] = 1; 141 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
142 {
143 if (texture != null)
144 assetUuids[texture.TextureID] = AssetType.Texture;
145 }
145 } 146 }
146 } 147 }
147 148
148 // If the prim is a sculpt then preserve this information too 149 // If the prim is a sculpt then preserve this information too
149 if (part.Shape.SculptTexture != UUID.Zero) 150 if (part.Shape.SculptTexture != UUID.Zero)
150 assetUuids[part.Shape.SculptTexture] = 1; 151 assetUuids[part.Shape.SculptTexture] = AssetType.Texture;
151 152
152 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 153 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
153 154
@@ -217,7 +218,7 @@ namespace OpenSim.Region.Framework.Scenes
217 /// </summary> 218 /// </summary>
218 /// <param name="scriptUuid"></param> 219 /// <param name="scriptUuid"></param>
219 /// <param name="assetUuids">Dictionary in which to record the references</param> 220 /// <param name="assetUuids">Dictionary in which to record the references</param>
220 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, int> assetUuids) 221 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, AssetType> assetUuids)
221 { 222 {
222 AssetBase scriptAsset = GetAsset(scriptUuid); 223 AssetBase scriptAsset = GetAsset(scriptUuid);
223 224
@@ -232,7 +233,9 @@ namespace OpenSim.Region.Framework.Scenes
232 { 233 {
233 UUID uuid = new UUID(uuidMatch.Value); 234 UUID uuid = new UUID(uuidMatch.Value);
234 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); 235 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid);
235 assetUuids[uuid] = 1; 236
237 // Assume AssetIDs embedded in scripts are textures
238 assetUuids[uuid] = AssetType.Texture;
236 } 239 }
237 } 240 }
238 } 241 }
@@ -242,7 +245,7 @@ namespace OpenSim.Region.Framework.Scenes
242 /// </summary> 245 /// </summary>
243 /// <param name="wearableAssetUuid"></param> 246 /// <param name="wearableAssetUuid"></param>
244 /// <param name="assetUuids">Dictionary in which to record the references</param> 247 /// <param name="assetUuids">Dictionary in which to record the references</param>
245 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, int> assetUuids) 248 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids)
246 { 249 {
247 AssetBase assetBase = GetAsset(wearableAssetUuid); 250 AssetBase assetBase = GetAsset(wearableAssetUuid);
248 251
@@ -257,8 +260,7 @@ namespace OpenSim.Region.Framework.Scenes
257 260
258 foreach (UUID uuid in wearableAsset.Textures.Values) 261 foreach (UUID uuid in wearableAsset.Textures.Values)
259 { 262 {
260 //m_log.DebugFormat("[ARCHIVER]: Got bodypart uuid {0}", uuid); 263 assetUuids[uuid] = AssetType.Texture;
261 assetUuids[uuid] = 1;
262 } 264 }
263 } 265 }
264 } 266 }
@@ -270,7 +272,7 @@ namespace OpenSim.Region.Framework.Scenes
270 /// </summary> 272 /// </summary>
271 /// <param name="sceneObject"></param> 273 /// <param name="sceneObject"></param>
272 /// <param name="assetUuids"></param> 274 /// <param name="assetUuids"></param>
273 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, int> assetUuids) 275 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids)
274 { 276 {
275 AssetBase objectAsset = GetAsset(sceneObjectUuid); 277 AssetBase objectAsset = GetAsset(sceneObjectUuid);
276 278
@@ -284,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes
284 } 286 }
285 } 287 }
286 288
287 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, int> assetUuids) 289 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids)
288 { 290 {
289 AssetBase assetBase = GetAsset(gestureUuid); 291 AssetBase assetBase = GetAsset(gestureUuid);
290 292
@@ -316,7 +318,7 @@ namespace OpenSim.Region.Framework.Scenes
316 // If it can be parsed as a UUID, it is an asset ID 318 // If it can be parsed as a UUID, it is an asset ID
317 UUID uuid; 319 UUID uuid;
318 if (UUID.TryParse(id, out uuid)) 320 if (UUID.TryParse(id, out uuid))
319 assetUuids[uuid] = 1; 321 assetUuids[uuid] = AssetType.Animation;
320 } 322 }
321 } 323 }
322 } 324 }