diff options
author | Melanie Thielker | 2008-08-19 07:11:58 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-08-19 07:11:58 +0000 |
commit | 29530f30296271f2d5641091e45d5f396a7d4dec (patch) | |
tree | c0c01f8eabe0b8c3b0db20b3eb3c3c68018d450c /OpenSim | |
parent | * This reverts a change where m_regions[RegionHandle] was replaced instead of... (diff) | |
download | opensim-SC_OLD-29530f30296271f2d5641091e45d5f396a7d4dec.zip opensim-SC_OLD-29530f30296271f2d5641091e45d5f396a7d4dec.tar.gz opensim-SC_OLD-29530f30296271f2d5641091e45d5f396a7d4dec.tar.bz2 opensim-SC_OLD-29530f30296271f2d5641091e45d5f396a7d4dec.tar.xz |
Attachment persistence!!! Patch #9170 (Mantis #1171)
Attachments now persist across logouts. Mostly untested.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 14 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 19 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 37 |
4 files changed, 61 insertions, 16 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 3459504..81cf372 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -528,22 +528,26 @@ namespace OpenSim.Framework | |||
528 | m_attachments[attachpoint][1] = asset; | 528 | m_attachments[attachpoint][1] = asset; |
529 | } | 529 | } |
530 | 530 | ||
531 | public void DetachAttachment(LLUUID itemID) | 531 | public int GetAttachpoint(LLUUID itemID) |
532 | { | 532 | { |
533 | int attachpoint = 0; | ||
534 | |||
535 | foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments) | 533 | foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments) |
536 | { | 534 | { |
537 | if(kvp.Value[0] == itemID) | 535 | if(kvp.Value[0] == itemID) |
538 | { | 536 | { |
539 | attachpoint = kvp.Key; | 537 | return kvp.Key; |
540 | break; | ||
541 | } | 538 | } |
542 | } | 539 | } |
540 | return 0; | ||
541 | } | ||
542 | |||
543 | public void DetachAttachment(LLUUID itemID) | ||
544 | { | ||
545 | int attachpoint = GetAttachpoint(itemID); | ||
543 | 546 | ||
544 | if(attachpoint > 0) | 547 | if(attachpoint > 0) |
545 | m_attachments.Remove(attachpoint); | 548 | m_attachments.Remove(attachpoint); |
546 | } | 549 | } |
550 | |||
547 | string GetAttachmentsString() | 551 | string GetAttachmentsString() |
548 | { | 552 | { |
549 | List<string> strings = new List<string>(); | 553 | List<string> strings = new List<string>(); |
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index c337907..a7d6349 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -47,11 +47,15 @@ namespace OpenSim.Framework.Communications.Cache | |||
47 | internal delegate void SendInventoryDescendentsDelegate( | 47 | internal delegate void SendInventoryDescendentsDelegate( |
48 | IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); | 48 | IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems); |
49 | 49 | ||
50 | public delegate void OnItemReceivedDelegate(LLUUID itemID); | ||
51 | |||
50 | /// <summary> | 52 | /// <summary> |
51 | /// Stores user profile and inventory data received from backend services for a particular user. | 53 | /// Stores user profile and inventory data received from backend services for a particular user. |
52 | /// </summary> | 54 | /// </summary> |
53 | public class CachedUserInfo | 55 | public class CachedUserInfo |
54 | { | 56 | { |
57 | public event OnItemReceivedDelegate OnItemReceived; | ||
58 | |||
55 | private static readonly ILog m_log | 59 | private static readonly ILog m_log |
56 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 60 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
57 | 61 | ||
@@ -306,6 +310,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
306 | { | 310 | { |
307 | folder.Items[itemInfo.ID] = itemInfo; | 311 | folder.Items[itemInfo.ID] = itemInfo; |
308 | } | 312 | } |
313 | |||
314 | if (OnItemReceived != null) | ||
315 | OnItemReceived(itemInfo.ID); | ||
309 | } | 316 | } |
310 | 317 | ||
311 | /// <summary> | 318 | /// <summary> |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 784d04c..e145f4a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -2308,15 +2308,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
2308 | EventManager.TriggerStopScript(part.LocalId, itemID); | 2308 | EventManager.TriggerStopScript(part.LocalId, itemID); |
2309 | } | 2309 | } |
2310 | 2310 | ||
2311 | // public void TestFunction() | ||
2312 | // { | ||
2313 | // IInventoryModule imod = RequestModuleInterface<IInventoryModule>(); | ||
2314 | // if (imod == null) | ||
2315 | // return; | ||
2316 | // | ||
2317 | // imod.TestFunction(); | ||
2318 | // } | ||
2319 | |||
2320 | public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, | 2311 | public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, |
2321 | uint AttachmentPt, uint ItemFlags, uint NextOwnerMask) | 2312 | uint AttachmentPt, uint ItemFlags, uint NextOwnerMask) |
2322 | { | 2313 | { |
@@ -2328,13 +2319,21 @@ namespace OpenSim.Region.Environment.Scenes | |||
2328 | return; | 2319 | return; |
2329 | } | 2320 | } |
2330 | 2321 | ||
2322 | RezSingleAttachment(att, remoteClient, itemID, AttachmentPt, | ||
2323 | ItemFlags, NextOwnerMask); | ||
2324 | } | ||
2325 | |||
2326 | public void RezSingleAttachment(SceneObjectGroup att, | ||
2327 | IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, | ||
2328 | uint ItemFlags, uint NextOwnerMask) | ||
2329 | { | ||
2331 | if (att.RootPart != null) | 2330 | if (att.RootPart != null) |
2332 | AttachmentPt = att.RootPart.AttachmentPoint; | 2331 | AttachmentPt = att.RootPart.AttachmentPoint; |
2333 | 2332 | ||
2334 | ScenePresence presence; | 2333 | ScenePresence presence; |
2335 | if(TryGetAvatar(remoteClient.AgentId, out presence)) | 2334 | if(TryGetAvatar(remoteClient.AgentId, out presence)) |
2336 | { | 2335 | { |
2337 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.GetFromAssetID()); | 2336 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.UUID); |
2338 | IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); | 2337 | IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>(); |
2339 | if(ava != null) | 2338 | if(ava != null) |
2340 | { | 2339 | { |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 5669af6..af7ae47 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -36,6 +36,7 @@ using libsecondlife.Packets; | |||
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications.Cache; | 38 | using OpenSim.Framework.Communications.Cache; |
39 | using OpenSim.Region.Environment.Interfaces; | ||
39 | using OpenSim.Region.Environment.Types; | 40 | using OpenSim.Region.Environment.Types; |
40 | using OpenSim.Region.Physics.Manager; | 41 | using OpenSim.Region.Physics.Manager; |
41 | 42 | ||
@@ -416,7 +417,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
416 | RegisterToEvents(); | 417 | RegisterToEvents(); |
417 | SetDirectionVectors(); | 418 | SetDirectionVectors(); |
418 | 419 | ||
419 | 420 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); | |
421 | userInfo.OnItemReceived += ItemReceived; | ||
420 | } | 422 | } |
421 | 423 | ||
422 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, | 424 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, |
@@ -604,6 +606,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
604 | /// </summary> | 606 | /// </summary> |
605 | public void MakeRootAgent(LLVector3 pos, bool isFlying) | 607 | public void MakeRootAgent(LLVector3 pos, bool isFlying) |
606 | { | 608 | { |
609 | IAvatarFactory ava = m_scene.RequestModuleInterface<IAvatarFactory>(); | ||
610 | if(ava != null) | ||
611 | { | ||
612 | ava.TryGetAvatarAppearance(m_uuid, out m_appearance); | ||
613 | } | ||
614 | |||
607 | // m_log.DebugFormat( | 615 | // m_log.DebugFormat( |
608 | // "[SCENE PRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2} at pos {3}", | 616 | // "[SCENE PRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2} at pos {3}", |
609 | // Name, UUID, m_scene.RegionInfo.RegionName, pos); | 617 | // Name, UUID, m_scene.RegionInfo.RegionName, pos); |
@@ -2862,5 +2870,32 @@ namespace OpenSim.Region.Environment.Scenes | |||
2862 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 2870 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
2863 | return flags; | 2871 | return flags; |
2864 | } | 2872 | } |
2873 | |||
2874 | private void ItemReceived(LLUUID itemID) | ||
2875 | { | ||
2876 | int attachpoint = m_appearance.GetAttachpoint(itemID); | ||
2877 | if (attachpoint == 0) | ||
2878 | return; | ||
2879 | |||
2880 | SceneObjectPart att = m_scene.GetSceneObjectPart(m_appearance.GetAttachedAsset(attachpoint)); | ||
2881 | |||
2882 | |||
2883 | // If this is null, then we have just rezzed in. Non null means | ||
2884 | // we're crossing | ||
2885 | // | ||
2886 | if (att != null) | ||
2887 | { | ||
2888 | System.Console.WriteLine("Attach from world {0}", itemID.ToString()); | ||
2889 | // Attach from world | ||
2890 | if(att.ParentGroup != null) | ||
2891 | m_scene.RezSingleAttachment(att.ParentGroup, ControllingClient, itemID, (uint)attachpoint, 0, 0); | ||
2892 | } | ||
2893 | else | ||
2894 | { | ||
2895 | System.Console.WriteLine("Rez attachment {0}", itemID.ToString()); | ||
2896 | // Rez from inventory | ||
2897 | m_scene.RezSingleAttachment(ControllingClient, itemID, (uint)attachpoint, 0, 0); | ||
2898 | } | ||
2899 | } | ||
2865 | } | 2900 | } |
2866 | } | 2901 | } |