From 67a2d6d8552fe09f0b9fb5b15df1d49b8eb29f2f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 17 Dec 2011 02:23:24 +0000 Subject: [PATCH] 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 --- OpenSim/Framework/ISceneEntity.cs | 1 + OpenSim/Framework/ISceneObject.cs | 6 +++++ .../World/Permissions/PermissionsModule.cs | 12 ++++++--- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +-- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 ---------- .../Framework/Scenes/SceneObjectGroup.cs | 2 ++ .../Framework/Scenes/SceneObjectPart.cs | 8 +++++- .../Avatar/XmlRpcGroups/GroupsModule.cs | 27 ++++++++++++++++++- 8 files changed, 52 insertions(+), 22 deletions(-) diff --git a/OpenSim/Framework/ISceneEntity.cs b/OpenSim/Framework/ISceneEntity.cs index c0ea302247..a9f21d258c 100644 --- a/OpenSim/Framework/ISceneEntity.cs +++ b/OpenSim/Framework/ISceneEntity.cs @@ -34,6 +34,7 @@ namespace OpenSim.Framework string Name { get; set; } UUID UUID { get; } uint LocalId { get; } + Vector3 AbsolutePosition { get; } } } diff --git a/OpenSim/Framework/ISceneObject.cs b/OpenSim/Framework/ISceneObject.cs index 18631f17b1..afac9b84f2 100644 --- a/OpenSim/Framework/ISceneObject.cs +++ b/OpenSim/Framework/ISceneObject.cs @@ -33,6 +33,12 @@ namespace OpenSim.Framework public interface ISceneObject { UUID UUID { get; } + + /// + /// The owner of this object. + /// + UUID OwnerID { get; set; } + ISceneObject CloneForNewScene(); string ToXml2(); string ExtraToXmlString(); diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 776038290b..cdecd2f471 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/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) + + /// + /// 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) + /// + /// + /// + /// + /// protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) { if (null == m_groupsModule) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1487c3519e..3b7c0d97b9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2757,7 +2757,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; @@ -2884,7 +2883,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; @@ -4307,7 +4305,7 @@ namespace OpenSim.Region.Framework.Scenes /// Get a scene object group that contains the prim with the given local id /// /// - /// null if no scene object group containing that prim is found + /// null if no scene object group containing that prim is found public SceneObjectGroup GetGroupByPrim(uint localID) { return m_sceneGraph.GetGroupByPrim(localID); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1af18e7309..d42094cb34 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/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) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1b28fcccf8..14648a1023 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3269,6 +3269,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(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 269b1653fa..bae8202582 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3386,7 +3386,13 @@ namespace OpenSim.Region.Framework.Scenes public void SetGroup(UUID groupID, IClientAPI client) { - _groupID = groupID; + // 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); m_updateFlag = 2; diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 630fcabac3..6ef2c5b9c2 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -225,6 +225,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; @@ -232,7 +233,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); } @@ -335,6 +336,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);