From 380962d3594b9a45625889975609ebf5dc4b3683 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 16 Sep 2012 16:45:57 -0700 Subject: [PATCH 1/3] HG2.0: Generalized the allowed HG appearances to be more than 1. --- .../EntityTransfer/HGEntityTransferModule.cs | 90 ++++++++++++------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index f3c5873bd5..0b386d3f67 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -56,41 +56,54 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected bool m_RestrictAppearanceAbroad; protected string m_AccountName; - protected AvatarAppearance m_ExportedAppearance; + protected List m_ExportedAppearances; + protected List m_Attachs; - protected AvatarAppearance ExportedAppearance + protected List ExportedAppearance { get { - if (m_ExportedAppearance != null) - return m_ExportedAppearance; + if (m_ExportedAppearances != null) + return m_ExportedAppearances; - string[] parts = m_AccountName.Split(); - if (parts.Length != 2) - { - m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Wrong user account name format {0}. Specify 'First Last'", m_AccountName); - return null; - } - UserAccount account = Scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]); - if (account == null) - { - m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unknown account {0}", m_AccountName); - return null; - } - m_ExportedAppearance = Scene.AvatarService.GetAppearance(account.PrincipalID); - if (m_ExportedAppearance != null) - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Successfully retrieved appearance for {0}", m_AccountName); + m_ExportedAppearances = new List(); + m_Attachs = new List(); - foreach (AvatarAttachment att in m_ExportedAppearance.GetAttachments()) + string[] names = m_AccountName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + + foreach (string name in names) { - InventoryItemBase item = new InventoryItemBase(att.ItemID, account.PrincipalID); - item = Scene.InventoryService.GetItem(item); - if (item != null) - m_ExportedAppearance.SetAttachment(att.AttachPoint, att.ItemID, item.AssetID); - else - m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve item {0} from inventory", att.ItemID); + string[] parts = name.Trim().Split(); + if (parts.Length != 2) + { + m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Wrong user account name format {0}. Specify 'First Last'", name); + return null; + } + UserAccount account = Scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]); + if (account == null) + { + m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unknown account {0}", m_AccountName); + return null; + } + AvatarAppearance a = Scene.AvatarService.GetAppearance(account.PrincipalID); + if (a != null) + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Successfully retrieved appearance for {0}", name); + + foreach (AvatarAttachment att in a.GetAttachments()) + { + InventoryItemBase item = new InventoryItemBase(att.ItemID, account.PrincipalID); + item = Scene.InventoryService.GetItem(item); + if (item != null) + a.SetAttachment(att.AttachPoint, att.ItemID, item.AssetID); + else + m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve item {0} from inventory {1}", att.ItemID, name); + } + + m_ExportedAppearances.Add(a); + m_Attachs.AddRange(a.GetAttachments()); } - return m_ExportedAppearance; + + return m_ExportedAppearances; } } @@ -270,13 +283,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (sp.Appearance.Wearables[i] == null) continue; - if (ExportedAppearance.Wearables[i] == null) + bool found = false; + foreach (AvatarAppearance a in ExportedAppearance) + if (a.Wearables[i] != null) + { + found = true; + break; + } + + if (!found) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); return false; } - if (sp.Appearance.Wearables[i][j].AssetID != ExportedAppearance.Wearables[i][j].AssetID) + found = false; + foreach (AvatarAppearance a in ExportedAppearance) + if (sp.Appearance.Wearables[i][j].AssetID == a.Wearables[i][j].AssetID) + { + found = true; + break; + } + + if (!found) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); return false; @@ -285,11 +314,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } // Check attachments - foreach (AvatarAttachment att in sp.Appearance.GetAttachments()) { bool found = false; - foreach (AvatarAttachment att2 in ExportedAppearance.GetAttachments()) + foreach (AvatarAttachment att2 in m_Attachs) { if (att2.AssetID == att.AssetID) { From 5e626ce55de0b12797f2da7819e15747721779e6 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 17 Sep 2012 13:02:56 +0100 Subject: [PATCH 2/3] script invocations cannot have void return type --- .../Attachments/TempAttachmentsModule.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs index cb89cd1133..d7fb272d2c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -130,37 +130,37 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val)); } - private void llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) + private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) { SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); if (hostPart == null) - return; + return 0; if (hostPart.ParentGroup.IsAttachment) - return; + return 0; IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface(); if (attachmentsModule == null) - return; + return 0; TaskInventoryItem item = hostPart.Inventory.GetInventoryItem(script); if (item == null) - return; + return 0; if ((item.PermsMask & 32) == 0) // PERMISSION_ATTACH - return; + return 0; ScenePresence target; if (!m_scene.TryGetScenePresence(item.PermsGranter, out target)) - return; + return 0; if (target.UUID != hostPart.ParentGroup.OwnerID) { uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions(); if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) - return; + return 0; hostPart.ParentGroup.SetOwnerId(target.UUID); hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId); @@ -183,7 +183,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); } - attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true); + return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true) ? 1 : 0; } } } From c7948a669a200af1f18b125c22467f02ecb4784d Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 17 Sep 2012 13:03:34 +0100 Subject: [PATCH 3/3] preventing a null reference exception from being thrown Signed-off-by: Melanie --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c2c0b96013..9c3c53df0c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5527,6 +5527,9 @@ namespace OpenSim.Region.Framework.Scenes public string GetExtraSetting(string name) { + if (m_extraSettings == null) + return String.Empty; + string val; if (!m_extraSettings.TryGetValue(name, out val))