diff options
author | UbitUmarov | 2018-05-12 19:16:23 +0100 |
---|---|---|
committer | UbitUmarov | 2018-05-12 19:16:23 +0100 |
commit | 0d83b9edc3f965c3d9061265bb6962002eea1efd (patch) | |
tree | f13e3fbd6046b121194d8c2d8f9bc255b9ca0b6c | |
parent | breaking map (warp3d) suport default map parameters. Planar not suported ( wi... (diff) | |
download | opensim-SC-0d83b9edc3f965c3d9061265bb6962002eea1efd.zip opensim-SC-0d83b9edc3f965c3d9061265bb6962002eea1efd.tar.gz opensim-SC-0d83b9edc3f965c3d9061265bb6962002eea1efd.tar.bz2 opensim-SC-0d83b9edc3f965c3d9061265bb6962002eea1efd.tar.xz |
create user with model: do not copy missing items; convert v1.0 to v2.0 wearables, fail if model has missing wearables
-rw-r--r-- | OpenSim/Services/UserAccountService/UserAccountService.cs | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 95c9e57..880517c 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs | |||
@@ -825,7 +825,6 @@ namespace OpenSim.Services.UserAccountService | |||
825 | return; | 825 | return; |
826 | } | 826 | } |
827 | 827 | ||
828 | |||
829 | try | 828 | try |
830 | { | 829 | { |
831 | CopyWearablesAndAttachments(destinationAgent, modelAccount.PrincipalID, modelAppearance); | 830 | CopyWearablesAndAttachments(destinationAgent, modelAccount.PrincipalID, modelAppearance); |
@@ -849,19 +848,24 @@ namespace OpenSim.Services.UserAccountService | |||
849 | /// </summary> | 848 | /// </summary> |
850 | private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance) | 849 | private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance) |
851 | { | 850 | { |
851 | |||
852 | AvatarWearable[] wearables = avatarAppearance.Wearables; | ||
853 | if(wearables.Length == 0) | ||
854 | throw new Exception("Model does not have wearables"); | ||
855 | |||
852 | // Get Clothing folder of receiver | 856 | // Get Clothing folder of receiver |
853 | InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing); | 857 | InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing); |
854 | // Get Current Outfit folder | ||
855 | InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit); | ||
856 | 858 | ||
857 | if (destinationFolder == null) | 859 | if (destinationFolder == null) |
858 | throw new Exception("Cannot locate folder(s)"); | 860 | throw new Exception("Cannot locate new clothing folder(s)"); |
859 | 861 | ||
860 | // Missing destination folder? This should *never* be the case | 862 | // Get Current Outfit folder |
863 | InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit); | ||
864 | |||
865 | // wrong destination folder type? create new | ||
861 | if (destinationFolder.Type != (short)FolderType.Clothing) | 866 | if (destinationFolder.Type != (short)FolderType.Clothing) |
862 | { | 867 | { |
863 | destinationFolder = new InventoryFolderBase(); | 868 | destinationFolder = new InventoryFolderBase(); |
864 | |||
865 | destinationFolder.ID = UUID.Random(); | 869 | destinationFolder.ID = UUID.Random(); |
866 | destinationFolder.Name = "Clothing"; | 870 | destinationFolder.Name = "Clothing"; |
867 | destinationFolder.Owner = destination; | 871 | destinationFolder.Owner = destination; |
@@ -869,21 +873,31 @@ namespace OpenSim.Services.UserAccountService | |||
869 | destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID; | 873 | destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID; |
870 | destinationFolder.Version = 1; | 874 | destinationFolder.Version = 1; |
871 | m_InventoryService.AddFolder(destinationFolder); // store base record | 875 | m_InventoryService.AddFolder(destinationFolder); // store base record |
872 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0}", source); | 876 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0} Clothing", source); |
873 | } | 877 | } |
874 | 878 | ||
875 | // Wearables | 879 | // Wearables |
876 | AvatarWearable[] wearables = avatarAppearance.Wearables; | 880 | AvatarWearable basewearable; |
877 | AvatarWearable wearable; | 881 | AvatarWearable newbasewearable; |
882 | WearableItem wearable; | ||
878 | 883 | ||
884 | // copy wearables creating new inventory entries | ||
885 | // converting from v1.0 wearables to v2.0 | ||
879 | for (int i = 0; i < wearables.Length; i++) | 886 | for (int i = 0; i < wearables.Length; i++) |
880 | { | 887 | { |
881 | wearable = wearables[i]; | 888 | basewearable = wearables[i]; |
882 | if (wearable[0].ItemID != UUID.Zero) | 889 | if(basewearable == null || basewearable.Count == 0) |
890 | continue; | ||
891 | |||
892 | newbasewearable = new AvatarWearable(); | ||
893 | int j = basewearable.Count - 1; | ||
894 | |||
895 | wearable = basewearable[j]; | ||
896 | if (wearable.ItemID != UUID.Zero) | ||
883 | { | 897 | { |
884 | m_log.DebugFormat("[XXX]: Getting item {0} from avie {1}", wearable[0].ItemID, source); | 898 | m_log.DebugFormat("[XXX]: Getting item {0} from avie {1}", wearable.ItemID, source); |
885 | // Get inventory item and copy it | 899 | // Get inventory item and copy it |
886 | InventoryItemBase item = m_InventoryService.GetItem(source, wearable[0].ItemID); | 900 | InventoryItemBase item = m_InventoryService.GetItem(source, wearable.ItemID); |
887 | 901 | ||
888 | if(item != null && item.AssetType == (int)AssetType.Link) | 902 | if(item != null && item.AssetType == (int)AssetType.Link) |
889 | { | 903 | { |
@@ -922,22 +936,22 @@ namespace OpenSim.Services.UserAccountService | |||
922 | m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); | 936 | m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); |
923 | 937 | ||
924 | // Wear item | 938 | // Wear item |
925 | AvatarWearable newWearable = new AvatarWearable(); | 939 | newbasewearable.Add(destinationItem.ID,wearable.AssetID); |
926 | newWearable.Wear(destinationItem.ID, wearable[0].AssetID); | ||
927 | avatarAppearance.SetWearable(i, newWearable); | ||
928 | 940 | ||
929 | // Add to Current Outfit | 941 | // Add to Current Outfit |
930 | CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID); | 942 | CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID); |
931 | } | 943 | } |
932 | else | 944 | else |
933 | { | 945 | { |
934 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID); | 946 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable.ItemID, destinationFolder.ID); |
935 | } | 947 | } |
936 | } | 948 | } |
949 | avatarAppearance.SetWearable(i, newbasewearable); | ||
937 | } | 950 | } |
938 | 951 | ||
939 | // Attachments | 952 | // Attachments |
940 | List<AvatarAttachment> attachments = avatarAppearance.GetAttachments(); | 953 | List<AvatarAttachment> attachments = avatarAppearance.GetAttachments(); |
954 | avatarAppearance.ClearAttachments(); | ||
941 | 955 | ||
942 | foreach (AvatarAttachment attachment in attachments) | 956 | foreach (AvatarAttachment attachment in attachments) |
943 | { | 957 | { |