From f206ffd5a8cd0ef362e972abf7375eb739f82e5b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 20 Aug 2008 01:48:51 +0000 Subject: Mantis #2003 - thank you, SachaMagne, for a patch that implements the first part of gesture persistence. ---------------------------------------------------------- Attachments no longer vanish on walking crossing. Teleport is still problematic, but will now be blocked with message "Inconsistent attachment state" rather than losing the attachment. Detach to be able to TP in that case. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 45 ++++++++++++++++++++ .../Environment/Modules/World/NPC/NPCAvatar.cs | 10 +++++ .../Region/Environment/Scenes/Scene.Inventory.cs | 5 +++ OpenSim/Region/Environment/Scenes/Scene.cs | 49 +++++++++++++++++++++- .../Scenes/SceneCommunicationService.cs | 6 +++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 41 ++++++++++++++---- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 9 ++++ 7 files changed, 157 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 059255f..83a1181 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 09f12b2..0b0f4c1 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 171868b..9c91725 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 363d0f8..fb2cbb6 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 f1af15f..4823aa1 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 cc70210..cf24c73 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 61ea966..e2e7081 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) { } -- cgit v1.1