diff options
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules')
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs | 155 |
1 files changed, 86 insertions, 69 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs b/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs index 35c8bd4..9080493 100644 --- a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs +++ b/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -69,7 +69,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
69 | { | 69 | { |
70 | console.Commands.AddCommand("userserver", false, "clone avatar", | 70 | console.Commands.AddCommand("userserver", false, "clone avatar", |
71 | "clone avatar <TemplateAvatarFirstName> <TemplateAvatarLastName> <TargetAvatarFirstName> <TargetAvatarLastName>", | 71 | "clone avatar <TemplateAvatarFirstName> <TemplateAvatarLastName> <TargetAvatarFirstName> <TargetAvatarLastName>", |
72 | "Clone the template avatar inventory into a target avatar", RunCommand); | 72 | "Clone the template avatar's inventory into a target avatar", RunCommand); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
@@ -145,7 +145,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
145 | 145 | ||
146 | if (removeTargetsClothes) | 146 | if (removeTargetsClothes) |
147 | { | 147 | { |
148 | //remove clothes and attachments from target avatar so that the end result isn't a merge of its existing clothes | 148 | //remove clothes and attachments from target avatar so that the end result isn't a merger of its existing clothes |
149 | // and the clothes from the template avatar. | 149 | // and the clothes from the template avatar. |
150 | RemoveClothesAndAttachments(avID); | 150 | RemoveClothesAndAttachments(avID); |
151 | } | 151 | } |
@@ -204,6 +204,9 @@ namespace OpenSim.Grid.UserServer.Modules | |||
204 | "POST", m_inventoryServerUrl + "GetItems/", templateFolderId.Guid); | 204 | "POST", m_inventoryServerUrl + "GetItems/", templateFolderId.Guid); |
205 | if ((templateItems != null) && (templateItems.Count > 0)) | 205 | if ((templateItems != null) && (templateItems.Count > 0)) |
206 | { | 206 | { |
207 | List<ClothesAttachment> wornClothes = new List<ClothesAttachment>(); | ||
208 | List<ClothesAttachment> attachedItems = new List<ClothesAttachment>(); | ||
209 | |||
207 | foreach (InventoryItemBase item in templateItems) | 210 | foreach (InventoryItemBase item in templateItems) |
208 | { | 211 | { |
209 | 212 | ||
@@ -213,7 +216,8 @@ namespace OpenSim.Grid.UserServer.Modules | |||
213 | int appearanceType = ItemIsPartOfAppearance(item, appearance); | 216 | int appearanceType = ItemIsPartOfAppearance(item, appearance); |
214 | if (appearanceType >= 0) | 217 | if (appearanceType >= 0) |
215 | { | 218 | { |
216 | UpdateAvatarAppearance(avID, appearanceType, clonedItemId, item.AssetID); | 219 | // UpdateAvatarAppearance(avID, appearanceType, clonedItemId, item.AssetID); |
220 | wornClothes.Add(new ClothesAttachment(appearanceType, clonedItemId, item.AssetID)); | ||
217 | } | 221 | } |
218 | 222 | ||
219 | if (appearance != null) | 223 | if (appearance != null) |
@@ -221,12 +225,36 @@ namespace OpenSim.Grid.UserServer.Modules | |||
221 | int attachment = appearance.GetAttachpoint(item.ID); | 225 | int attachment = appearance.GetAttachpoint(item.ID); |
222 | if (attachment > 0) | 226 | if (attachment > 0) |
223 | { | 227 | { |
224 | UpdateAvatarAttachment(avID, attachment, clonedItemId, item.AssetID); | 228 | //UpdateAvatarAttachment(avID, attachment, clonedItemId, item.AssetID); |
229 | attachedItems.Add(new ClothesAttachment(attachment, clonedItemId, item.AssetID)); | ||
225 | } | 230 | } |
226 | } | 231 | } |
227 | success = true; | 232 | success = true; |
228 | } | 233 | } |
229 | } | 234 | } |
235 | |||
236 | if ((wornClothes.Count > 0) || (attachedItems.Count > 0)) | ||
237 | { | ||
238 | //Update the worn clothes and attachments | ||
239 | AvatarAppearance targetAppearance = GetAppearance(avID); | ||
240 | if (targetAppearance != null) | ||
241 | { | ||
242 | foreach (ClothesAttachment wornItem in wornClothes) | ||
243 | { | ||
244 | targetAppearance.Wearables[wornItem.Type].AssetID = wornItem.AssetID; | ||
245 | targetAppearance.Wearables[wornItem.Type].ItemID = wornItem.ItemID; | ||
246 | } | ||
247 | |||
248 | foreach (ClothesAttachment wornItem in attachedItems) | ||
249 | { | ||
250 | targetAppearance.SetAttachment(wornItem.Type, wornItem.ItemID, wornItem.AssetID); | ||
251 | } | ||
252 | |||
253 | m_userDataBaseService.UpdateUserAppearance(avID, targetAppearance); | ||
254 | wornClothes.Clear(); | ||
255 | attachedItems.Clear(); | ||
256 | } | ||
257 | } | ||
230 | } | 258 | } |
231 | 259 | ||
232 | List<InventoryFolderBase> subFolders = FindSubFolders(templateFolder.ID.Guid, templateFolders); | 260 | List<InventoryFolderBase> subFolders = FindSubFolders(templateFolder.ID.Guid, templateFolders); |
@@ -288,40 +316,27 @@ namespace OpenSim.Grid.UserServer.Modules | |||
288 | 316 | ||
289 | private void UpdateAvatarAppearance(UUID avatarID, int wearableType, UUID itemID, UUID assetID) | 317 | private void UpdateAvatarAppearance(UUID avatarID, int wearableType, UUID itemID, UUID assetID) |
290 | { | 318 | { |
291 | AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID); | 319 | AvatarAppearance appearance = GetAppearance(avatarID); |
292 | if (appearance == null) | ||
293 | { | ||
294 | appearance = CreateDefaultAppearance(avatarID); | ||
295 | } | ||
296 | 320 | ||
297 | appearance.Wearables[wearableType].AssetID = assetID; | 321 | appearance.Wearables[wearableType].AssetID = assetID; |
298 | appearance.Wearables[wearableType].ItemID = itemID; | 322 | appearance.Wearables[wearableType].ItemID = itemID; |
299 | 323 | ||
300 | m_userDataBaseService.UpdateUserAppearance(avatarID, appearance); | 324 | m_userDataBaseService.UpdateUserAppearance(avatarID, appearance); |
301 | |||
302 | } | 325 | } |
303 | 326 | ||
327 | |||
304 | private void UpdateAvatarAttachment(UUID avatarID, int attachmentPoint, UUID itemID, UUID assetID) | 328 | private void UpdateAvatarAttachment(UUID avatarID, int attachmentPoint, UUID itemID, UUID assetID) |
305 | { | 329 | { |
306 | AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID); | 330 | AvatarAppearance appearance = GetAppearance(avatarID); |
307 | if (appearance == null) | ||
308 | { | ||
309 | appearance = CreateDefaultAppearance(avatarID); | ||
310 | } | ||
311 | 331 | ||
312 | appearance.SetAttachment(attachmentPoint, itemID, assetID); | 332 | appearance.SetAttachment(attachmentPoint, itemID, assetID); |
313 | 333 | ||
314 | m_userDataBaseService.UpdateUserAppearance(avatarID, appearance); | 334 | m_userDataBaseService.UpdateUserAppearance(avatarID, appearance); |
315 | |||
316 | } | 335 | } |
317 | 336 | ||
318 | private void RemoveClothesAndAttachments(UUID avatarID) | 337 | private void RemoveClothesAndAttachments(UUID avatarID) |
319 | { | 338 | { |
320 | AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID); | 339 | AvatarAppearance appearance = GetAppearance(avatarID); |
321 | if (appearance == null) | ||
322 | { | ||
323 | appearance = CreateDefaultAppearance(avatarID); | ||
324 | } | ||
325 | 340 | ||
326 | appearance.ClearWearables(); | 341 | appearance.ClearWearables(); |
327 | appearance.ClearAttachments(); | 342 | appearance.ClearAttachments(); |
@@ -329,6 +344,16 @@ namespace OpenSim.Grid.UserServer.Modules | |||
329 | 344 | ||
330 | } | 345 | } |
331 | 346 | ||
347 | private AvatarAppearance GetAppearance(UUID avatarID) | ||
348 | { | ||
349 | AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID); | ||
350 | if (appearance == null) | ||
351 | { | ||
352 | appearance = CreateDefaultAppearance(avatarID); | ||
353 | } | ||
354 | return appearance; | ||
355 | } | ||
356 | |||
332 | private UUID FindFolderID(string name, List<InventoryFolderBase> folders) | 357 | private UUID FindFolderID(string name, List<InventoryFolderBase> folders) |
333 | { | 358 | { |
334 | foreach (InventoryFolderBase folder in folders) | 359 | foreach (InventoryFolderBase folder in folders) |
@@ -398,27 +423,6 @@ namespace OpenSim.Grid.UserServer.Modules | |||
398 | item.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; | 423 | item.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; |
399 | item.GroupPermissions = item.GroupPermissions & item.NextPermissions; | 424 | item.GroupPermissions = item.GroupPermissions & item.NextPermissions; |
400 | 425 | ||
401 | //set all items to +mod/+copy/- transfer | ||
402 | //if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
403 | // item.CurrentPermissions |= (uint)PermissionMask.Modify; | ||
404 | |||
405 | //if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
406 | // item.CurrentPermissions |= (uint)PermissionMask.Copy; | ||
407 | |||
408 | //if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) | ||
409 | // item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | ||
410 | |||
411 | //if ((item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
412 | // item.NextPermissions |= (uint)PermissionMask.Modify; | ||
413 | |||
414 | //if ((item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
415 | // item.NextPermissions |= (uint)PermissionMask.Copy; | ||
416 | |||
417 | //if ((item.NextPermissions & (uint)PermissionMask.Transfer) != 0) | ||
418 | // item.NextPermissions &= ~(uint)PermissionMask.Transfer; | ||
419 | |||
420 | //if ((item.EveryOnePermissions & (uint)PermissionMask.Transfer) != 0) | ||
421 | // item.EveryOnePermissions &= ~(uint)PermissionMask.Transfer; | ||
422 | } | 426 | } |
423 | 427 | ||
424 | private AvatarAppearance CreateDefaultAppearance(UUID avatarId) | 428 | private AvatarAppearance CreateDefaultAppearance(UUID avatarId) |
@@ -496,33 +500,46 @@ namespace OpenSim.Grid.UserServer.Modules | |||
496 | } | 500 | } |
497 | #endregion | 501 | #endregion |
498 | 502 | ||
503 | public enum PermissionMask | ||
504 | { | ||
505 | None = 0, | ||
506 | Transfer = 8192, | ||
507 | Modify = 16384, | ||
508 | Copy = 32768, | ||
509 | Move = 524288, | ||
510 | Damage = 1048576, | ||
511 | All = 2147483647, | ||
512 | } | ||
499 | 513 | ||
500 | } | 514 | public enum WearableType |
501 | public enum PermissionMask | 515 | { |
502 | { | 516 | Shape = 0, |
503 | None = 0, | 517 | Skin = 1, |
504 | Transfer = 8192, | 518 | Hair = 2, |
505 | Modify = 16384, | 519 | Eyes = 3, |
506 | Copy = 32768, | 520 | Shirt = 4, |
507 | Move = 524288, | 521 | Pants = 5, |
508 | Damage = 1048576, | 522 | Shoes = 6, |
509 | All = 2147483647, | 523 | Socks = 7, |
510 | } | 524 | Jacket = 8, |
525 | Gloves = 9, | ||
526 | Undershirt = 10, | ||
527 | Underpants = 11, | ||
528 | Skirt = 12, | ||
529 | } | ||
511 | 530 | ||
512 | public enum WearableType | 531 | public class ClothesAttachment |
513 | { | 532 | { |
514 | Shape = 0, | 533 | public int Type; |
515 | Skin = 1, | 534 | public UUID ItemID; |
516 | Hair = 2, | 535 | public UUID AssetID; |
517 | Eyes = 3, | 536 | |
518 | Shirt = 4, | 537 | public ClothesAttachment(int type, UUID itemID, UUID assetID) |
519 | Pants = 5, | 538 | { |
520 | Shoes = 6, | 539 | Type = type; |
521 | Socks = 7, | 540 | ItemID = itemID; |
522 | Jacket = 8, | 541 | AssetID = assetID; |
523 | Gloves = 9, | 542 | } |
524 | Undershirt = 10, | 543 | } |
525 | Underpants = 11, | ||
526 | Skirt = 12, | ||
527 | } | 544 | } |
528 | } | 545 | } |