diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 71b8eb0196..8aac9ce88e 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -299,7 +299,8 @@ namespace OpenSim.Framework public delegate void ScriptReset(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID); public delegate void GetScriptRunning(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID); public delegate void SetScriptRunning(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, bool running); - + public delegate void ActivateGesture(IClientAPI client, LLUUID gestureid, LLUUID assetId); + public delegate void DeactivateGesture(IClientAPI client, LLUUID gestureid); public delegate void TerrainUnacked(IClientAPI remoteClient, int patchX, int patchY); @@ -512,6 +513,10 @@ namespace OpenSim.Framework event UpdateVector OnAutoPilotGo; event TerrainUnacked OnUnackedTerrain; + event ActivateGesture OnActivateGesture; + event DeactivateGesture OnDeactivateGesture; + + // void ActivateGesture(LLUUID assetId, LLUUID gestureId); // [Obsolete("IClientAPI.OutPacket SHOULD NOT EXIST outside of LLClientView please refactor appropriately.")] void OutPacket(Packet newPack, ThrottleOutPacketType packType); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 059255f812..83a118101d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -247,6 +247,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP private GetScriptRunning handlerGetScriptRunning = null; private SetScriptRunning handlerSetScriptRunning = null; private UpdateVector handlerAutoPilotGo = null; + //Gesture + private ActivateGesture handlerActivateGesture = null; + private DeactivateGesture handlerDeactivateGesture = null; //private TerrainUnacked handlerUnackedTerrain = null; @@ -931,6 +934,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event TerrainUnacked OnUnackedTerrain; + public event ActivateGesture OnActivateGesture; + public event DeactivateGesture OnDeactivateGesture; + + + // voire si c'est necessaire + public void ActivateGesture(LLUUID assetId, LLUUID gestureId) + { + } + public void DeactivateGesture(LLUUID assetId, LLUUID gestureId) + { + } #region Scene/Avatar to Client /// @@ -2065,6 +2079,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion + // Gesture + + + #region Appearance/ Wearables Methods /// @@ -5879,6 +5897,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion + #region Gesture Managment + + case PacketType.ActivateGestures: + ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack; + handlerActivateGesture = OnActivateGesture; + if (handlerActivateGesture != null) + { + handlerActivateGesture(this, + activateGesturePacket.Data[0].AssetID, + activateGesturePacket.Data[0].ItemID); + } + else m_log.Error("Null pointer for activateGesture"); + + break; + + case PacketType.DeactivateGestures: + DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack; + handlerDeactivateGesture = OnDeactivateGesture; + if (handlerDeactivateGesture != null) + { + handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID); + } + break; + + #endregion + + #region unimplemented handlers case PacketType.StartPingCheck: diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 09f12b29dc..0b0f4c17c4 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -306,9 +306,19 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public event RegionHandleRequest OnRegionHandleRequest; public event ParcelInfoRequest OnParcelInfoRequest; + public event ActivateGesture OnActivateGesture; + public event DeactivateGesture OnDeactivateGesture; + #pragma warning restore 67 #endregion + + public void ActivateGesture(LLUUID assetId, LLUUID gestureId) + { + } + public void DeactivateGesture(LLUUID assetId, LLUUID gestureId) + { + } #region Overrriden Methods IGNORE diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 171868bae2..9c917250bf 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -2343,6 +2343,11 @@ namespace OpenSim.Region.Environment.Scenes } } + public void AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, LLQuaternion rot, LLVector3 pos) + { + m_innerScene.AttachObject(controllingClient, localID, attachPoint, rot, pos); + } + public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient) { ScenePresence presence; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 363d0f8408..fb2cbb6841 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2020,7 +2020,7 @@ namespace OpenSim.Region.Environment.Scenes // with the deeded object, it goes back to them grp.SetFromAssetID(grp.RootPart.LastOwnerID); - m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition); + AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition); } } } @@ -2161,9 +2161,56 @@ namespace OpenSim.Region.Environment.Scenes client.OnUnackedTerrain += TerrainUnAcked; + //Gesture + client.OnActivateGesture += ActivateGesture; + client.OnDeactivateGesture += DeactivateGesture; + // EventManager.TriggerOnNewClient(client); } + // Gesture + public virtual void ActivateGesture(IClientAPI client, LLUUID assetId, LLUUID gestureId) + { + // UserProfileCacheService User = CommsManager.SecureInventoryService.UpdateItem(gestureid, agentID); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); + + if (userInfo != null) + { + + InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); + if (item != null) + { + item.Flags = 1; + userInfo.UpdateItem(item); + } + else m_log.Error("Unable to find gesture"); + } + else m_log.Error("Gesture : Unable to find user "); + + m_log.DebugFormat("Asset : {0} gesture :{1}", gestureId.ToString(), assetId.ToString()); + } + + public virtual void DeactivateGesture(IClientAPI client, LLUUID gestureId) + { + // UserProfileCacheService User = CommsManager.SecureInventoryService.UpdateItem(gestureid, agentID); + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); + + if (userInfo != null) + { + + InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); + if (item != null) + { + item.Flags = 0; + userInfo.UpdateItem(item); + } + else m_log.Error("Unable to find gesture"); + } + else m_log.Error("Gesture : Unable to find user "); + + m_log.DebugFormat("gesture : {0} ", gestureId.ToString()); + } + public virtual void TeleportClientHome(LLUUID agentId, IClientAPI client) { UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index f1af15fd1e..4823aa1103 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -615,6 +615,12 @@ namespace OpenSim.Region.Environment.Scenes if (destRegionUp) { + if(!avatar.ValidateAttachments()) + { + avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); + return; + } + avatar.Close(); // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index cc70210f68..cf24c7332a 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1972,7 +1972,7 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 vel = m_velocity; ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); - if (neighbourRegion != null) + if (neighbourRegion != null && ValidateAttachments()) { // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar // This means we need to remove the current caps handler here and possibly compensate later, @@ -2343,15 +2343,41 @@ namespace OpenSim.Region.Environment.Scenes } } - public void CrossAttachmentsIntoNewRegion(ulong regionHandle) + public bool ValidateAttachments() + { + lock (m_attachments) + { + // Validate + foreach (SceneObjectGroup gobj in m_attachments) + { + if(gobj == null) + return false; + + if(gobj.RootPart == null) + { + return false; + } + } + } + return true; + } + + public bool CrossAttachmentsIntoNewRegion(ulong regionHandle) { m_attachmentsTransported = true; lock (m_attachments) { + // Validate + foreach (SceneObjectGroup gobj in m_attachments) + { + if(gobj == null || gobj.RootPart == null) + return false; + } + foreach (SceneObjectGroup gobj in m_attachments) { // If the prim group is null then something must have happened to it! - if (gobj != null) + if (gobj != null && gobj.RootPart != null) { // Set the parent localID to 0 so it transfers over properly. gobj.RootPart.SetParentLocalId(0); @@ -2362,6 +2388,8 @@ namespace OpenSim.Region.Environment.Scenes } } m_attachments.Clear(); + + return true; } } @@ -2903,10 +2931,9 @@ namespace OpenSim.Region.Environment.Scenes m_log.InfoFormat("[ATTACHEMENT] Attach from world {0}", itemID.ToString()); - // Attach from world - if (att.ParentGroup != null) - m_scene.RezSingleAttachment(att.ParentGroup, - ControllingClient, itemID, (uint)attachpoint, 0, 0); + // Attach from world, if not already attached + if (att.ParentGroup != null && !att.IsAttachment) + m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, (uint)0, att.ParentGroup.GroupRotation, LLVector3.Zero); } } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 61ea96618b..e2e70811db 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -207,6 +207,10 @@ namespace OpenSim.Region.Examples.SimpleModule public event RegionHandleRequest OnRegionHandleRequest; public event ParcelInfoRequest OnParcelInfoRequest; + public event ActivateGesture OnActivateGesture; + public event DeactivateGesture OnDeactivateGesture; + + #pragma warning restore 67 private LLUUID myID = LLUUID.Random(); @@ -295,6 +299,11 @@ namespace OpenSim.Region.Examples.SimpleModule get { return m_scene; } } + public virtual void ActivateGesture(LLUUID assetId, LLUUID gestureId) + { + } + + public virtual void OutPacket(Packet newPack, ThrottleOutPacketType packType) { }