aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs130
1 files changed, 115 insertions, 15 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index ddb69c4..3789ee9 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -489,6 +489,7 @@ namespace OpenSim.Region.ClientStack.Linden
489 cost = (uint)baseCost; 489 cost = (uint)baseCost;
490 } 490 }
491 491
492 // check funds
492 if (mm != null) 493 if (mm != null)
493 { 494 {
494 if (!mm.UploadCovered(client.AgentId, (int)cost)) 495 if (!mm.UploadCovered(client.AgentId, (int)cost))
@@ -565,26 +566,41 @@ namespace OpenSim.Region.ClientStack.Linden
565 sbyte assType = 0; 566 sbyte assType = 0;
566 sbyte inType = 0; 567 sbyte inType = 0;
567 568
569 IClientAPI client = null;
570
571 IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>();
572 if (mm != null)
573 {
574 // make sure client still has enougth credit
575 if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost))
576 {
577 m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
578 if (client != null)
579 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
580 return;
581 }
582 }
583
568 if (inventoryType == "sound") 584 if (inventoryType == "sound")
569 { 585 {
570 inType = 1; 586 inType = (sbyte)InventoryType.Sound;
571 assType = 1; 587 assType = (sbyte)AssetType.Sound;
572 } 588 }
573 else if (inventoryType == "animation") 589 else if (inventoryType == "animation")
574 { 590 {
575 inType = 19; 591 inType = (sbyte)InventoryType.Animation;
576 assType = 20; 592 assType = (sbyte)AssetType.Animation;
577 } 593 }
578 else if (inventoryType == "wearable") 594 else if (inventoryType == "wearable")
579 { 595 {
580 inType = 18; 596 inType = (sbyte)InventoryType.Wearable;
581 switch (assetType) 597 switch (assetType)
582 { 598 {
583 case "bodypart": 599 case "bodypart":
584 assType = 13; 600 assType = (sbyte)AssetType.Bodypart;
585 break; 601 break;
586 case "clothing": 602 case "clothing":
587 assType = 5; 603 assType = (sbyte)AssetType.Clothing;
588 break; 604 break;
589 } 605 }
590 } 606 }
@@ -601,6 +617,7 @@ namespace OpenSim.Region.ClientStack.Linden
601 OSDArray texture_list = (OSDArray)request["texture_list"]; 617 OSDArray texture_list = (OSDArray)request["texture_list"];
602 SceneObjectGroup grp = null; 618 SceneObjectGroup grp = null;
603 619
620 // create and store texture assets
604 List<UUID> textures = new List<UUID>(); 621 List<UUID> textures = new List<UUID>();
605 for (int i = 0; i < texture_list.Count; i++) 622 for (int i = 0; i < texture_list.Count; i++)
606 { 623 {
@@ -608,14 +625,97 @@ namespace OpenSim.Region.ClientStack.Linden
608 textureAsset.Data = texture_list[i].AsBinary(); 625 textureAsset.Data = texture_list[i].AsBinary();
609 m_assetService.Store(textureAsset); 626 m_assetService.Store(textureAsset);
610 textures.Add(textureAsset.FullID); 627 textures.Add(textureAsset.FullID);
628
629 // save it to inventory
630 if (AddNewInventoryItem != null)
631 {
632 string name = assetName;
633 if (name.Length > 25)
634 name = name.Substring(0, 24);
635 name += "_Texture#" + i.ToString();
636 InventoryItemBase texitem = new InventoryItemBase();
637 texitem.Owner = m_HostCapsObj.AgentID;
638 texitem.CreatorId = m_HostCapsObj.AgentID.ToString();
639 texitem.CreatorData = String.Empty;
640 texitem.ID = UUID.Random();
641 texitem.AssetID = textureAsset.FullID;
642 texitem.Description = "mesh model texture";
643 texitem.Name = name;
644 texitem.AssetType = (int)AssetType.Texture;
645 texitem.InvType = (int)InventoryType.Texture;
646 texitem.Folder = UUID.Zero; // send to default
647
648 // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
649 // (owner) permissions. This becomes a problem if next permissions are changed.
650 texitem.CurrentPermissions
651 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
652
653 texitem.BasePermissions = (uint)PermissionMask.All;
654 texitem.EveryOnePermissions = 0;
655 texitem.NextPermissions = (uint)PermissionMask.All;
656 texitem.CreationDate = Util.UnixTimeSinceEpoch();
657
658 AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0);
659 texitem = null;
660 }
661
662 textureAsset = null;
663
611 } 664 }
612 665
666 // create and store meshs assets
667 List<UUID> meshAssets = new List<UUID>();
613 for (int i = 0; i < mesh_list.Count; i++) 668 for (int i = 0; i < mesh_list.Count; i++)
614 { 669 {
670 AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, "");
671 meshAsset.Data = mesh_list[i].AsBinary();
672 m_assetService.Store(meshAsset);
673 meshAssets.Add(meshAsset.FullID);
674
675 // save it to inventory
676 if (AddNewInventoryItem != null)
677 {
678 string name = assetName;
679 if (name.Length > 25)
680 name = name.Substring(0, 24);
681 name += "_Mesh#" + i.ToString();
682 InventoryItemBase meshitem = new InventoryItemBase();
683 meshitem.Owner = m_HostCapsObj.AgentID;
684 meshitem.CreatorId = m_HostCapsObj.AgentID.ToString();
685 meshitem.CreatorData = String.Empty;
686 meshitem.ID = UUID.Random();
687 meshitem.AssetID = meshAsset.FullID;
688 meshitem.Description = "mesh ";
689 meshitem.Name = name;
690 meshitem.AssetType = (int)AssetType.Mesh;
691 meshitem.InvType = (int)InventoryType.Mesh;
692 meshitem.Folder = UUID.Zero; // send to default
693
694 // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
695 // (owner) permissions. This becomes a problem if next permissions are changed.
696 meshitem.CurrentPermissions
697 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
698
699 meshitem.BasePermissions = (uint)PermissionMask.All;
700 meshitem.EveryOnePermissions = 0;
701 meshitem.NextPermissions = (uint)PermissionMask.All;
702 meshitem.CreationDate = Util.UnixTimeSinceEpoch();
703
704 AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0);
705 meshitem = null;
706 }
707
708 meshAsset = null;
709 }
710
711 // build prims from instances
712 for (int i = 0; i < instance_list.Count; i++)
713 {
615 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); 714 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
616 715
617 Primitive.TextureEntry textureEntry 716 Primitive.TextureEntry textureEntry
618 = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); 717 = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
718
619 OSDMap inner_instance_list = (OSDMap)instance_list[i]; 719 OSDMap inner_instance_list = (OSDMap)instance_list[i];
620 720
621 OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; 721 OSDArray face_list = (OSDArray)inner_instance_list["face_list"];
@@ -660,14 +760,14 @@ namespace OpenSim.Region.ClientStack.Linden
660 760
661 pbs.TextureEntry = textureEntry.GetBytes(); 761 pbs.TextureEntry = textureEntry.GetBytes();
662 762
663 AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); 763 int meshindx = inner_instance_list["mesh"].AsInteger();
664 meshAsset.Data = mesh_list[i].AsBinary(); 764 if (meshAssets.Count > meshindx)
665 m_assetService.Store(meshAsset); 765 {
666 766 pbs.SculptEntry = true;
667 pbs.SculptEntry = true; 767 pbs.SculptType = (byte)SculptType.Mesh;
668 pbs.SculptTexture = meshAsset.FullID; 768 pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction
669 pbs.SculptType = (byte)SculptType.Mesh; 769 // data will be requested from asset on rez (i hope)
670 pbs.SculptData = meshAsset.Data; 770 }
671 771
672 Vector3 position = inner_instance_list["position"].AsVector3(); 772 Vector3 position = inner_instance_list["position"].AsVector3();
673 Vector3 scale = inner_instance_list["scale"].AsVector3(); 773 Vector3 scale = inner_instance_list["scale"].AsVector3();