Browse Source

Fix bug where objects could not be set to a new group if the group had been created in that client session, or if no other action has been performed on the object.

There were two problems here:
1) On object group update, we looked for the group is the IClientAPI group cache rather than in the groups service.  This fails to groups created newly in that session
2) On object group update, we weren't setting the HasGroupChanged flag.  This meant that the change was not persisted unless some other action set this flag.
This commit fixes these issues and hopefully addresses http://opensimulator.org/mantis/view.php?id=5588
This commit also moves HandleObjectGroupUpdate() to the GroupsModule from the Scene.PacketHandlers.cs file
Justin Clark-Casey (justincc) 12 years ago
parent
commit
f9137c923b

+ 1 - 0
OpenSim/Framework/ISceneEntity.cs

@@ -34,6 +34,7 @@ namespace OpenSim.Framework
         string Name { get; set; }
         UUID UUID { get; }
         uint LocalId { get; }
+
         Vector3 AbsolutePosition { get; }
     }
 }

+ 6 - 0
OpenSim/Framework/ISceneObject.cs

@@ -33,6 +33,12 @@ namespace OpenSim.Framework
     public interface ISceneObject
     {
         UUID UUID { get; }
+
+        /// <summary>
+        /// The owner of this object.
+        /// </summary>
+        UUID OwnerID { get; set; }
+
         ISceneObject CloneForNewScene();
         string ToXml2();
         string ExtraToXmlString();

+ 9 - 3
OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs

@@ -384,9 +384,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions
             if (m_debugPermissions)
                 m_log.Debug("[PERMISSIONS]: " + permissionCalled + " was called from " + m_scene.RegionInfo.RegionName);
         }
-    
-        // Checks if the given group is active and if the user is a group member
-        // with the powers requested (powers = 0 for no powers check)
+
+        /// <summary>
+        /// Checks if the given group is active and if the user is a group member
+        /// with the powers requested (powers = 0 for no powers check)
+        /// </summary>
+        /// <param name="groupID"></param>
+        /// <param name="userID"></param>
+        /// <param name="powers"></param>
+        /// <returns></returns>
         protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
         {
             if (null == m_groupsModule)

+ 1 - 3
OpenSim/Region/Framework/Scenes/Scene.cs

@@ -2776,7 +2776,6 @@ namespace OpenSim.Region.Framework.Scenes
 
         public virtual void SubscribeToClientParcelEvents(IClientAPI client)
         {
-            client.OnObjectGroupRequest += m_sceneGraph.HandleObjectGroupUpdate;
             client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel;
             client.OnParcelSetOtherCleanTime += LandChannel.SetParcelOtherCleanTime;
             client.OnParcelBuy += ProcessParcelBuy;
@@ -2903,7 +2902,6 @@ namespace OpenSim.Region.Framework.Scenes
 
         public virtual void UnSubscribeToClientParcelEvents(IClientAPI client)
         {
-            client.OnObjectGroupRequest -= m_sceneGraph.HandleObjectGroupUpdate;
             client.OnParcelReturnObjectsRequest -= LandChannel.ReturnObjectsInParcel;
             client.OnParcelSetOtherCleanTime -= LandChannel.SetParcelOtherCleanTime;
             client.OnParcelBuy -= ProcessParcelBuy;
@@ -4287,7 +4285,7 @@ namespace OpenSim.Region.Framework.Scenes
         /// Get a scene object group that contains the prim with the given local id
         /// </summary>
         /// <param name="localID"></param>
-        /// <returns>null if no scene object group containing that prim is found</returns>
+        /// <returns>null if no scene object group containing that prim is found</returns>        
         public SceneObjectGroup GetGroupByPrim(uint localID)
         {
             return m_sceneGraph.GetGroupByPrim(localID);

+ 0 - 14
OpenSim/Region/Framework/Scenes/SceneGraph.cs

@@ -575,20 +575,6 @@ namespace OpenSim.Region.Framework.Scenes
             }
         }
 
-        protected internal void HandleObjectGroupUpdate(
-            IClientAPI remoteClient, UUID GroupID, uint objectLocalID, UUID Garbage)
-        {
-            if (!remoteClient.IsGroupMember(GroupID))
-                return;
-
-            SceneObjectGroup group = GetGroupByPrim(objectLocalID);
-            if (group != null)
-            {
-                if (group.OwnerID == remoteClient.AgentId)
-                    group.SetGroup(GroupID, remoteClient);
-            }
-        }
-
         protected internal ScenePresence CreateAndAddChildScenePresence(
             IClientAPI client, AvatarAppearance appearance, PresenceType type)
         {

+ 2 - 0
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs

@@ -3211,6 +3211,8 @@ namespace OpenSim.Region.Framework.Scenes
                 part.Inventory.ChangeInventoryGroup(GroupID);
             }
 
+            HasGroupChanged = true;
+            
             // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
             // for the same object with very different properties.  The caller must schedule the update.
             //ScheduleGroupForFullUpdate();

+ 5 - 0
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs

@@ -3344,6 +3344,11 @@ namespace OpenSim.Region.Framework.Scenes
 
         public void SetGroup(UUID groupID, IClientAPI client)
         {
+            // Scene.AddNewPrims() calls with client == null so can't use this.
+//            m_log.DebugFormat(
+//                "[SCENE OBJECT PART]: Setting group for {0} to {1} for {2}",
+//                Name, groupID, OwnerID);
+
             GroupID = groupID;
             if (client != null)
                 SendPropertiesToClient(client);

+ 26 - 1
OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs

@@ -218,6 +218,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
             if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
 
             client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
+            client.OnObjectGroupRequest += HandleObjectGroupUpdate;
             client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
             client.OnDirFindQuery += OnDirFindQuery;
             client.OnRequestAvatarProperties += OnRequestAvatarProperties;
@@ -225,7 +226,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
             // Used for Notices and Group Invites/Accept/Reject
             client.OnInstantMessage += OnInstantMessage;
 
-            // Send client thier groups information.
+            // Send client their groups information.
             SendAgentGroupDataUpdate(client, client.AgentId);
         }
 
@@ -328,6 +329,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
             remoteClient.SendGroupNameReply(GroupID, GroupName);
         }
 
+        private void HandleObjectGroupUpdate(
+            IClientAPI remoteClient, UUID GroupID, uint objectLocalID, UUID Garbage)
+        {
+            GroupMembershipData gmd = GetMembershipData(GroupID, remoteClient.AgentId);
+
+            if (gmd == null)
+            {
+//                m_log.WarnFormat(
+//                    "[GROUPS]: User {0} is not a member of group {1} so they can't update {2} to this group",
+//                    remoteClient.Name, GroupID, objectLocalID);
+
+                return;
+            }
+
+            SceneObjectGroup so = ((Scene)remoteClient.Scene).GetGroupByPrim(objectLocalID);
+            if (so != null)
+            {
+                if (so.OwnerID == remoteClient.AgentId)
+                {
+                    so.SetGroup(GroupID, remoteClient);
+                }
+            }
+        }
+
         private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
         {
             if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);