aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs90
1 files changed, 59 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index f3c5873..0b386d3 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
56 56
57 protected bool m_RestrictAppearanceAbroad; 57 protected bool m_RestrictAppearanceAbroad;
58 protected string m_AccountName; 58 protected string m_AccountName;
59 protected AvatarAppearance m_ExportedAppearance; 59 protected List<AvatarAppearance> m_ExportedAppearances;
60 protected List<AvatarAttachment> m_Attachs;
60 61
61 protected AvatarAppearance ExportedAppearance 62 protected List<AvatarAppearance> ExportedAppearance
62 { 63 {
63 get 64 get
64 { 65 {
65 if (m_ExportedAppearance != null) 66 if (m_ExportedAppearances != null)
66 return m_ExportedAppearance; 67 return m_ExportedAppearances;
67 68
68 string[] parts = m_AccountName.Split(); 69 m_ExportedAppearances = new List<AvatarAppearance>();
69 if (parts.Length != 2) 70 m_Attachs = new List<AvatarAttachment>();
70 { 71
71 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Wrong user account name format {0}. Specify 'First Last'", m_AccountName); 72 string[] names = m_AccountName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
72 return null;
73 }
74 UserAccount account = Scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]);
75 if (account == null)
76 {
77 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unknown account {0}", m_AccountName);
78 return null;
79 }
80 m_ExportedAppearance = Scene.AvatarService.GetAppearance(account.PrincipalID);
81 if (m_ExportedAppearance != null)
82 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Successfully retrieved appearance for {0}", m_AccountName);
83 73
84 foreach (AvatarAttachment att in m_ExportedAppearance.GetAttachments()) 74 foreach (string name in names)
85 { 75 {
86 InventoryItemBase item = new InventoryItemBase(att.ItemID, account.PrincipalID); 76 string[] parts = name.Trim().Split();
87 item = Scene.InventoryService.GetItem(item); 77 if (parts.Length != 2)
88 if (item != null) 78 {
89 m_ExportedAppearance.SetAttachment(att.AttachPoint, att.ItemID, item.AssetID); 79 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Wrong user account name format {0}. Specify 'First Last'", name);
90 else 80 return null;
91 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve item {0} from inventory", att.ItemID); 81 }
82 UserAccount account = Scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]);
83 if (account == null)
84 {
85 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unknown account {0}", m_AccountName);
86 return null;
87 }
88 AvatarAppearance a = Scene.AvatarService.GetAppearance(account.PrincipalID);
89 if (a != null)
90 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Successfully retrieved appearance for {0}", name);
91
92 foreach (AvatarAttachment att in a.GetAttachments())
93 {
94 InventoryItemBase item = new InventoryItemBase(att.ItemID, account.PrincipalID);
95 item = Scene.InventoryService.GetItem(item);
96 if (item != null)
97 a.SetAttachment(att.AttachPoint, att.ItemID, item.AssetID);
98 else
99 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve item {0} from inventory {1}", att.ItemID, name);
100 }
101
102 m_ExportedAppearances.Add(a);
103 m_Attachs.AddRange(a.GetAttachments());
92 } 104 }
93 return m_ExportedAppearance; 105
106 return m_ExportedAppearances;
94 } 107 }
95 } 108 }
96 109
@@ -270,13 +283,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
270 if (sp.Appearance.Wearables[i] == null) 283 if (sp.Appearance.Wearables[i] == null)
271 continue; 284 continue;
272 285
273 if (ExportedAppearance.Wearables[i] == null) 286 bool found = false;
287 foreach (AvatarAppearance a in ExportedAppearance)
288 if (a.Wearables[i] != null)
289 {
290 found = true;
291 break;
292 }
293
294 if (!found)
274 { 295 {
275 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); 296 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i);
276 return false; 297 return false;
277 } 298 }
278 299
279 if (sp.Appearance.Wearables[i][j].AssetID != ExportedAppearance.Wearables[i][j].AssetID) 300 found = false;
301 foreach (AvatarAppearance a in ExportedAppearance)
302 if (sp.Appearance.Wearables[i][j].AssetID == a.Wearables[i][j].AssetID)
303 {
304 found = true;
305 break;
306 }
307
308 if (!found)
280 { 309 {
281 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); 310 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i);
282 return false; 311 return false;
@@ -285,11 +314,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
285 } 314 }
286 315
287 // Check attachments 316 // Check attachments
288
289 foreach (AvatarAttachment att in sp.Appearance.GetAttachments()) 317 foreach (AvatarAttachment att in sp.Appearance.GetAttachments())
290 { 318 {
291 bool found = false; 319 bool found = false;
292 foreach (AvatarAttachment att2 in ExportedAppearance.GetAttachments()) 320 foreach (AvatarAttachment att2 in m_Attachs)
293 { 321 {
294 if (att2.AssetID == att.AssetID) 322 if (att2.AssetID == att.AssetID)
295 { 323 {