diff options
author | Melanie | 2013-01-27 01:09:07 +0000 |
---|---|---|
committer | Melanie | 2013-01-27 01:09:07 +0000 |
commit | e6e6e8ab1541044135d28514d402b64ed06825a0 (patch) | |
tree | a9051a927857f0ec15187d5faee6bfc222fb0461 /OpenSim/Region/CoreModules | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Prevent items being destroyed by rename operations. Renaming of a wearable also (diff) | |
download | opensim-SC-e6e6e8ab1541044135d28514d402b64ed06825a0.zip opensim-SC-e6e6e8ab1541044135d28514d402b64ed06825a0.tar.gz opensim-SC-e6e6e8ab1541044135d28514d402b64ed06825a0.tar.bz2 opensim-SC-e6e6e8ab1541044135d28514d402b64ed06825a0.tar.xz |
Merge branch 'avination' into careminster
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 263 |
1 files changed, 259 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index a070ff8..691326c 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -677,20 +677,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
677 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) | 677 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) |
678 | { | 678 | { |
679 | IInventoryService invService = m_scene.InventoryService; | 679 | IInventoryService invService = m_scene.InventoryService; |
680 | 680 | bool resetwearable = false; | |
681 | if (invService.GetRootFolder(userID) != null) | 681 | if (invService.GetRootFolder(userID) != null) |
682 | { | 682 | { |
683 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | 683 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
684 | { | 684 | { |
685 | for (int j = 0; j < appearance.Wearables[i].Count; j++) | 685 | for (int j = 0; j < appearance.Wearables[i].Count; j++) |
686 | { | 686 | { |
687 | // Check if the default wearables are not set | ||
687 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) | 688 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) |
689 | { | ||
690 | switch ((WearableType) i) | ||
691 | { | ||
692 | case WearableType.Eyes: | ||
693 | case WearableType.Hair: | ||
694 | case WearableType.Shape: | ||
695 | case WearableType.Skin: | ||
696 | //case WearableType.Underpants: | ||
697 | TryAndRepair((WearableType)i, invService, userID, appearance); | ||
698 | resetwearable = true; | ||
699 | m_log.Warn("[AVFACTORY]: UUID.Zero Wearables, passing fake values."); | ||
700 | resetwearable = true; | ||
701 | break; | ||
702 | |||
703 | } | ||
688 | continue; | 704 | continue; |
705 | } | ||
689 | 706 | ||
690 | // Ignore ruth's assets | 707 | // Ignore ruth's assets except for the body parts! missing body parts fail avatar appearance on V1 |
691 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) | 708 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) |
709 | { | ||
710 | switch ((WearableType)i) | ||
711 | { | ||
712 | case WearableType.Eyes: | ||
713 | case WearableType.Hair: | ||
714 | case WearableType.Shape: | ||
715 | case WearableType.Skin: | ||
716 | //case WearableType.Underpants: | ||
717 | TryAndRepair((WearableType)i, invService, userID, appearance); | ||
718 | |||
719 | m_log.WarnFormat("[AVFACTORY]: {0} Default Wearables, passing existing values.", (WearableType)i); | ||
720 | resetwearable = true; | ||
721 | break; | ||
722 | |||
723 | } | ||
692 | continue; | 724 | continue; |
693 | 725 | } | |
726 | |||
694 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); | 727 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); |
695 | baseItem = invService.GetItem(baseItem); | 728 | baseItem = invService.GetItem(baseItem); |
696 | 729 | ||
@@ -704,17 +737,239 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
704 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", | 737 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", |
705 | appearance.Wearables[i][j].ItemID, (WearableType)i); | 738 | appearance.Wearables[i][j].ItemID, (WearableType)i); |
706 | 739 | ||
707 | appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID); | 740 | TryAndRepair((WearableType)i, invService, userID, appearance); |
741 | resetwearable = true; | ||
742 | |||
708 | } | 743 | } |
709 | } | 744 | } |
710 | } | 745 | } |
746 | |||
747 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
748 | if (appearance.Wearables[(int) WearableType.Eyes] == null) | ||
749 | { | ||
750 | m_log.WarnFormat("[AVFACTORY]: {0} Eyes are Null, passing existing values.", (WearableType.Eyes)); | ||
751 | |||
752 | TryAndRepair(WearableType.Eyes, invService, userID, appearance); | ||
753 | resetwearable = true; | ||
754 | } | ||
755 | else | ||
756 | { | ||
757 | if (appearance.Wearables[(int) WearableType.Eyes][0].ItemID == UUID.Zero) | ||
758 | { | ||
759 | m_log.WarnFormat("[AVFACTORY]: Eyes are UUID.Zero are broken, {0} {1}", | ||
760 | appearance.Wearables[(int) WearableType.Eyes][0].ItemID, | ||
761 | appearance.Wearables[(int) WearableType.Eyes][0].AssetID); | ||
762 | TryAndRepair(WearableType.Eyes, invService, userID, appearance); | ||
763 | resetwearable = true; | ||
764 | |||
765 | } | ||
766 | |||
767 | } | ||
768 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
769 | if (appearance.Wearables[(int)WearableType.Shape] == null) | ||
770 | { | ||
771 | m_log.WarnFormat("[AVFACTORY]: {0} shape is Null, passing existing values.", (WearableType.Shape)); | ||
772 | |||
773 | TryAndRepair(WearableType.Shape, invService, userID, appearance); | ||
774 | resetwearable = true; | ||
775 | } | ||
776 | else | ||
777 | { | ||
778 | if (appearance.Wearables[(int)WearableType.Shape][0].ItemID == UUID.Zero) | ||
779 | { | ||
780 | m_log.WarnFormat("[AVFACTORY]: Shape is UUID.Zero and broken, {0} {1}", | ||
781 | appearance.Wearables[(int)WearableType.Shape][0].ItemID, | ||
782 | appearance.Wearables[(int)WearableType.Shape][0].AssetID); | ||
783 | TryAndRepair(WearableType.Shape, invService, userID, appearance); | ||
784 | resetwearable = true; | ||
785 | |||
786 | } | ||
787 | |||
788 | } | ||
789 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
790 | if (appearance.Wearables[(int)WearableType.Hair] == null) | ||
791 | { | ||
792 | m_log.WarnFormat("[AVFACTORY]: {0} Hair is Null, passing existing values.", (WearableType.Hair)); | ||
793 | |||
794 | TryAndRepair(WearableType.Hair, invService, userID, appearance); | ||
795 | resetwearable = true; | ||
796 | } | ||
797 | else | ||
798 | { | ||
799 | if (appearance.Wearables[(int)WearableType.Hair][0].ItemID == UUID.Zero) | ||
800 | { | ||
801 | m_log.WarnFormat("[AVFACTORY]: Hair is UUID.Zero and broken, {0} {1}", | ||
802 | appearance.Wearables[(int)WearableType.Hair][0].ItemID, | ||
803 | appearance.Wearables[(int)WearableType.Hair][0].AssetID); | ||
804 | TryAndRepair(WearableType.Hair, invService, userID, appearance); | ||
805 | resetwearable = true; | ||
806 | |||
807 | } | ||
808 | |||
809 | } | ||
810 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
811 | if (appearance.Wearables[(int)WearableType.Skin] == null) | ||
812 | { | ||
813 | m_log.WarnFormat("[AVFACTORY]: {0} Skin is Null, passing existing values.", (WearableType.Skin)); | ||
814 | |||
815 | TryAndRepair(WearableType.Skin, invService, userID, appearance); | ||
816 | resetwearable = true; | ||
817 | } | ||
818 | else | ||
819 | { | ||
820 | if (appearance.Wearables[(int)WearableType.Skin][0].ItemID == UUID.Zero) | ||
821 | { | ||
822 | m_log.WarnFormat("[AVFACTORY]: Skin is UUID.Zero and broken, {0} {1}", | ||
823 | appearance.Wearables[(int)WearableType.Skin][0].ItemID, | ||
824 | appearance.Wearables[(int)WearableType.Skin][0].AssetID); | ||
825 | TryAndRepair(WearableType.Skin, invService, userID, appearance); | ||
826 | resetwearable = true; | ||
827 | |||
828 | } | ||
829 | |||
830 | } | ||
831 | if (resetwearable) | ||
832 | { | ||
833 | ScenePresence presence = null; | ||
834 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
835 | { | ||
836 | presence.ControllingClient.SendWearables(presence.Appearance.Wearables, | ||
837 | presence.Appearance.Serial++); | ||
838 | } | ||
839 | } | ||
840 | |||
711 | } | 841 | } |
712 | else | 842 | else |
713 | { | 843 | { |
714 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); | 844 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); |
715 | } | 845 | } |
716 | } | 846 | } |
847 | private void TryAndRepair(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance) | ||
848 | { | ||
849 | UUID defaultwearable = GetDefaultItem(type); | ||
850 | if (defaultwearable != UUID.Zero) | ||
851 | { | ||
852 | UUID newInvItem = UUID.Random(); | ||
853 | InventoryItemBase itembase = new InventoryItemBase(newInvItem, userID) | ||
854 | { | ||
855 | AssetID = | ||
856 | defaultwearable, | ||
857 | AssetType | ||
858 | = | ||
859 | (int) | ||
860 | AssetType | ||
861 | .Bodypart, | ||
862 | CreatorId | ||
863 | = | ||
864 | userID | ||
865 | .ToString | ||
866 | (), | ||
867 | //InvType = (int)InventoryType.Wearable, | ||
868 | |||
869 | Description | ||
870 | = | ||
871 | "Failed Wearable Replacement", | ||
872 | Folder = | ||
873 | invService | ||
874 | .GetFolderForType | ||
875 | (userID, | ||
876 | AssetType | ||
877 | .Bodypart) | ||
878 | .ID, | ||
879 | Flags = (uint) type, | ||
880 | Name = Enum.GetName(typeof (WearableType), type), | ||
881 | BasePermissions = (uint) PermissionMask.Copy, | ||
882 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
883 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
884 | GroupPermissions = (uint) PermissionMask.Copy, | ||
885 | NextPermissions = (uint) PermissionMask.Copy | ||
886 | }; | ||
887 | invService.AddItem(itembase); | ||
888 | UUID LinkInvItem = UUID.Random(); | ||
889 | itembase = new InventoryItemBase(LinkInvItem, userID) | ||
890 | { | ||
891 | AssetID = | ||
892 | newInvItem, | ||
893 | AssetType | ||
894 | = | ||
895 | (int) | ||
896 | AssetType | ||
897 | .Link, | ||
898 | CreatorId | ||
899 | = | ||
900 | userID | ||
901 | .ToString | ||
902 | (), | ||
903 | InvType = (int) InventoryType.Wearable, | ||
904 | |||
905 | Description | ||
906 | = | ||
907 | "Failed Wearable Replacement", | ||
908 | Folder = | ||
909 | invService | ||
910 | .GetFolderForType | ||
911 | (userID, | ||
912 | AssetType | ||
913 | .CurrentOutfitFolder) | ||
914 | .ID, | ||
915 | Flags = (uint) type, | ||
916 | Name = Enum.GetName(typeof (WearableType), type), | ||
917 | BasePermissions = (uint) PermissionMask.Copy, | ||
918 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
919 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
920 | GroupPermissions = (uint) PermissionMask.Copy, | ||
921 | NextPermissions = (uint) PermissionMask.Copy | ||
922 | }; | ||
923 | invService.AddItem(itembase); | ||
924 | appearance.Wearables[(int)type] = new AvatarWearable(newInvItem, GetDefaultItem(type)); | ||
925 | ScenePresence presence = null; | ||
926 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
927 | { | ||
928 | m_scene.SendInventoryUpdate(presence.ControllingClient, | ||
929 | invService.GetFolderForType(userID, | ||
930 | AssetType | ||
931 | .CurrentOutfitFolder), | ||
932 | false, true); | ||
933 | } | ||
934 | } | ||
935 | } | ||
936 | private UUID GetDefaultItem(WearableType wearable) | ||
937 | { | ||
938 | // These are Urban male.. but it doesn't matter as long as the assets exist. | ||
939 | UUID ret = UUID.Zero; | ||
940 | switch (wearable) | ||
941 | { | ||
942 | case WearableType.Eyes: | ||
943 | ret = new UUID("46d7f979-c060-0ad6-5d3c-8de38c941c8d"); | ||
944 | break; | ||
945 | case WearableType.Hair: | ||
946 | ret = new UUID("21ae002d-57af-441a-81ff-86f5f674b9b9"); | ||
947 | break; | ||
948 | case WearableType.Pants: | ||
949 | ret = new UUID("e3440698-48fd-41ac-af9b-f680547cbef2"); | ||
950 | break; | ||
951 | case WearableType.Shape: | ||
952 | ret = new UUID("7c1f1354-2aba-4e55-8357-1545c2c003ce"); | ||
953 | break; | ||
954 | case WearableType.Shirt: | ||
955 | ret = new UUID("f8fefa00-b019-4072-9c04-ff79c65348b9"); | ||
956 | break; | ||
957 | case WearableType.Shoes: | ||
958 | ret = new UUID("6455d2cf-0ee1-4c9a-9812-da03371bf719"); | ||
959 | break; | ||
960 | case WearableType.Skin: | ||
961 | ret = new UUID("29c99e80-cf59-4fa0-9f8e-e4a1ccaf2fa3"); | ||
962 | break; | ||
963 | case WearableType.Socks: | ||
964 | ret = new UUID("96472ac3-1e18-49e5-b2e4-17c03791ea96"); | ||
965 | break; | ||
966 | case WearableType.Underpants: | ||
967 | ret = new UUID("d6c7b174-8a2d-473f-a80f-3b7d7b7b3a96"); | ||
968 | break; | ||
969 | } | ||
717 | 970 | ||
971 | return ret; | ||
972 | } | ||
718 | #endregion | 973 | #endregion |
719 | 974 | ||
720 | #region Client Event Handlers | 975 | #region Client Event Handlers |