diff options
author | Melanie | 2012-09-17 14:15:22 +0100 |
---|---|---|
committer | Melanie | 2012-09-17 14:15:22 +0100 |
commit | 1dd75fcdb476d20b96efba64a842ac82000c400d (patch) | |
tree | b51eed8de604358841d3cb56db267eaf379c3d3f /OpenSim/Region/CoreModules | |
parent | Merge branch 'avination' into careminster (diff) | |
parent | preventing a null reference exception from being thrown (diff) | |
download | opensim-SC-1dd75fcdb476d20b96efba64a842ac82000c400d.zip opensim-SC-1dd75fcdb476d20b96efba64a842ac82000c400d.tar.gz opensim-SC-1dd75fcdb476d20b96efba64a842ac82000c400d.tar.bz2 opensim-SC-1dd75fcdb476d20b96efba64a842ac82000c400d.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 90 |
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 0f1a381..4c786ff 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 | ||
@@ -275,13 +288,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
275 | if (sp.Appearance.Wearables[i] == null) | 288 | if (sp.Appearance.Wearables[i] == null) |
276 | continue; | 289 | continue; |
277 | 290 | ||
278 | if (ExportedAppearance.Wearables[i] == null) | 291 | bool found = false; |
292 | foreach (AvatarAppearance a in ExportedAppearance) | ||
293 | if (a.Wearables[i] != null) | ||
294 | { | ||
295 | found = true; | ||
296 | break; | ||
297 | } | ||
298 | |||
299 | if (!found) | ||
279 | { | 300 | { |
280 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | 301 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); |
281 | return false; | 302 | return false; |
282 | } | 303 | } |
283 | 304 | ||
284 | if (sp.Appearance.Wearables[i][j].AssetID != ExportedAppearance.Wearables[i][j].AssetID) | 305 | found = false; |
306 | foreach (AvatarAppearance a in ExportedAppearance) | ||
307 | if (sp.Appearance.Wearables[i][j].AssetID == a.Wearables[i][j].AssetID) | ||
308 | { | ||
309 | found = true; | ||
310 | break; | ||
311 | } | ||
312 | |||
313 | if (!found) | ||
285 | { | 314 | { |
286 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | 315 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); |
287 | return false; | 316 | return false; |
@@ -290,11 +319,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
290 | } | 319 | } |
291 | 320 | ||
292 | // Check attachments | 321 | // Check attachments |
293 | |||
294 | foreach (AvatarAttachment att in sp.Appearance.GetAttachments()) | 322 | foreach (AvatarAttachment att in sp.Appearance.GetAttachments()) |
295 | { | 323 | { |
296 | bool found = false; | 324 | bool found = false; |
297 | foreach (AvatarAttachment att2 in ExportedAppearance.GetAttachments()) | 325 | foreach (AvatarAttachment att2 in m_Attachs) |
298 | { | 326 | { |
299 | if (att2.AssetID == att.AssetID) | 327 | if (att2.AssetID == att.AssetID) |
300 | { | 328 | { |