private void RemapWornItems(UUID botID, AvatarAppearance appearance) { // save before Clear calls List <AvatarWearable> wearables = appearance.GetWearables(); List <AvatarAttachment> attachments = appearance.GetAttachments(); appearance.ClearWearables(); appearance.ClearAttachments(); // Remap bot outfit with new item IDs foreach (AvatarWearable w in wearables) { AvatarWearable newWearable = new AvatarWearable(w); // store a reversible back-link to the original inventory item ID. newWearable.ItemID = w.ItemID ^ botID; appearance.SetWearable(newWearable); } foreach (AvatarAttachment a in attachments) { // store a reversible back-link to the original inventory item ID. UUID itemID = a.ItemID ^ botID; appearance.SetAttachment(a.AttachPoint, true, itemID, a.AssetID); } }
//private bool childShadowAvatar = false; public Avatar(SimClient TheClient, World world, string regionName, Dictionary <uint, SimClient> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater) { m_world = world; m_clientThreads = clientThreads; m_regionName = regionName; m_regionHandle = regionHandle; m_regionTerraform = regionTerraform; m_regionWaterHeight = regionWater; OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); ControllingClient = TheClient; localid = 8880000 + (this.m_world._localNumber++); Pos = ControllingClient.startpos; visualParams = new byte[218]; for (int i = 0; i < 218; i++) { visualParams[i] = 100; } Wearables = new AvatarWearable[13]; //should be 13 of these for (int i = 0; i < 13; i++) { Wearables[i] = new AvatarWearable(); } this.Wearables[0].AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); this.Wearables[0].ItemID = LLUUID.Random(); this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); }
public virtual void CacheWearableData(UUID principalID, AvatarWearable cachedWearable) { Dictionary <string, object> sendData = new Dictionary <string, object>(); //sendData["SCOPEID"] = scopeID.ToString(); sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); sendData["METHOD"] = "cachewearabledata"; sendData["WEARABLES"] = OSDParser.SerializeJsonString(cachedWearable.Pack()); string reqString = WebUtils.BuildQueryString(sendData); // MainConsole.Instance.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("AvatarServerURI"); foreach (string m_ServerURI in serverURIs) { AsynchronousRestObjectRequester.MakeRequest("POST", m_ServerURI, reqString); } } catch (Exception e) { MainConsole.Instance.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting avatar server: {0}", e.Message); } }
public void CacheWearableData(UUID principalID, AvatarWearable wearable) { if (!m_enableCacheBakedTextures) { IAssetService service = m_registry.RequestModuleInterface <IAssetService>(); if (service != null) { //Remove the old baked textures then from the DB as we don't want to keep them around foreach (UUID texture in wearable.GetItems().Values) { service.Delete(texture.ToString()); } } return; } wearable.MaxItems = 0; //Unlimited items /*AvatarBaseData baseData = new AvatarBaseData(); * AvatarBaseData[] av = m_CacheDatabase.Get("PrincipalID", principalID.ToString()); * foreach (AvatarBaseData abd in av) * { * //If we have one already made, keep what is already there * if (abd.Data["Name"] == "CachedWearables") * { * baseData = abd; * OSDArray array = (OSDArray)OSDParser.DeserializeJson(abd.Data["Value"]); * AvatarWearable w = new AvatarWearable(); * w.MaxItems = 0; //Unlimited items * w.Unpack(array); * foreach (KeyValuePair<UUID, UUID> kvp in w.GetItems()) * { * wearable.Add(kvp.Key, kvp.Value); * } * } * } * //If we don't have one, set it up for saving a new one * if (baseData.Data == null) * { * baseData.PrincipalID = principalID; * baseData.Data = new Dictionary<string, string>(); * baseData.Data.Add("Name", "CachedWearables"); * } * baseData.Data["Value"] = OSDParser.SerializeJsonString(wearable.Pack()); * try * { * bool store = m_CacheDatabase.Store(baseData); * if (!store) * { * m_log.Warn("[AvatarService]: Issue saving the cached wearables to the database."); * } * } * catch * { * }*/ }
/// <summary> /// Tell the Avatar Service about these baked textures and items /// </summary> /// <param name="sp"></param> /// <param name="textureEntry"></param> /// <param name="wearables"></param> private void CacheWearableData(IScenePresence sp, Primitive.TextureEntry textureEntry, WearableCache[] wearables) { if (textureEntry == null || wearables.Length == 0) { return; } AvatarWearable cachedWearable = new AvatarWearable(); cachedWearable.MaxItems = 0; //Unlimited items for (int i = 0; i < wearables.Length; i++) { WearableCache item = wearables[i]; if (textureEntry.FaceTextures[item.TextureIndex] != null) { cachedWearable.Add(item.CacheID, textureEntry.FaceTextures[item.TextureIndex].TextureID); } } m_scene.AvatarService.CacheWearableData(sp.UUID, cachedWearable); }
private byte[] CacheWearableData(Dictionary <string, object> request) { UUID user = UUID.Zero; if (!request.ContainsKey("UserID") || !request.ContainsKey("WEARABLES")) { return(FailureResult()); } if (!UUID.TryParse(request["UserID"].ToString(), out user)) { return(FailureResult()); } AvatarWearable w = new AvatarWearable(); OSDArray array = (OSDArray)OSDParser.DeserializeJson(request["WEARABLES"].ToString()); w.Unpack(array); m_AvatarService.CacheWearableData(user, w); return(SuccessResult()); }
private void AppendWearablesDetailReport(ScenePresence sp, StringBuilder sb) { sb.AppendFormat("\nWearables for {0}\n", sp.Name); ConsoleDisplayTable cdt = new ConsoleDisplayTable(); cdt.AddColumn("Type", 10); cdt.AddColumn("Item UUID", ConsoleDisplayUtil.UuidSize); cdt.AddColumn("Asset UUID", ConsoleDisplayUtil.UuidSize); for (int i = (int)WearableType.Shape; i < (int)WearableType.Physics; i++) { AvatarWearable aw = sp.Appearance.Wearables[i]; for (int j = 0; j < aw.Count; j++) { WearableItem wi = aw[j]; cdt.AddRow(Enum.GetName(typeof(WearableType), i), wi.ItemID, wi.AssetID); } } sb.Append(cdt.ToString()); }
public void CacheWearableData(UUID principalID, AvatarWearable cachedWearable) { }
protected void CreateDefaultAppearanceEntries(UUID principalID) { m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Bodypart); InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID); eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); eyes.Name = "Default Eyes"; eyes.CreatorId = principalID.ToString(); eyes.AssetType = (int)AssetType.Bodypart; eyes.InvType = (int)InventoryType.Wearable; eyes.Folder = bodyPartsFolder.ID; eyes.BasePermissions = (uint)PermissionMask.All; eyes.CurrentPermissions = (uint)PermissionMask.All; eyes.EveryOnePermissions = (uint)PermissionMask.All; eyes.GroupPermissions = (uint)PermissionMask.All; eyes.NextPermissions = (uint)PermissionMask.All; eyes.Flags = (uint)WearableType.Eyes; m_InventoryService.AddItem(eyes); InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID); shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET; shape.Name = "Default Shape"; shape.CreatorId = principalID.ToString(); shape.AssetType = (int)AssetType.Bodypart; shape.InvType = (int)InventoryType.Wearable; shape.Folder = bodyPartsFolder.ID; shape.BasePermissions = (uint)PermissionMask.All; shape.CurrentPermissions = (uint)PermissionMask.All; shape.EveryOnePermissions = (uint)PermissionMask.All; shape.GroupPermissions = (uint)PermissionMask.All; shape.NextPermissions = (uint)PermissionMask.All; shape.Flags = (uint)WearableType.Shape; m_InventoryService.AddItem(shape); InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID); skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET; skin.Name = "Default Skin"; skin.CreatorId = principalID.ToString(); skin.AssetType = (int)AssetType.Bodypart; skin.InvType = (int)InventoryType.Wearable; skin.Folder = bodyPartsFolder.ID; skin.BasePermissions = (uint)PermissionMask.All; skin.CurrentPermissions = (uint)PermissionMask.All; skin.EveryOnePermissions = (uint)PermissionMask.All; skin.GroupPermissions = (uint)PermissionMask.All; skin.NextPermissions = (uint)PermissionMask.All; skin.Flags = (uint)WearableType.Skin; m_InventoryService.AddItem(skin); InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID); hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET; hair.Name = "Default Hair"; hair.CreatorId = principalID.ToString(); hair.AssetType = (int)AssetType.Bodypart; hair.InvType = (int)InventoryType.Wearable; hair.Folder = bodyPartsFolder.ID; hair.BasePermissions = (uint)PermissionMask.All; hair.CurrentPermissions = (uint)PermissionMask.All; hair.EveryOnePermissions = (uint)PermissionMask.All; hair.GroupPermissions = (uint)PermissionMask.All; hair.NextPermissions = (uint)PermissionMask.All; hair.Flags = (uint)WearableType.Hair; m_InventoryService.AddItem(hair); InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Clothing); InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID); shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET; shirt.Name = "Default Shirt"; shirt.CreatorId = principalID.ToString(); shirt.AssetType = (int)AssetType.Clothing; shirt.InvType = (int)InventoryType.Wearable; shirt.Folder = clothingFolder.ID; shirt.BasePermissions = (uint)PermissionMask.All; shirt.CurrentPermissions = (uint)PermissionMask.All; shirt.EveryOnePermissions = (uint)PermissionMask.All; shirt.GroupPermissions = (uint)PermissionMask.All; shirt.NextPermissions = (uint)PermissionMask.All; shirt.Flags = (uint)WearableType.Shirt; m_InventoryService.AddItem(shirt); InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID); pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET; pants.Name = "Default Pants"; pants.CreatorId = principalID.ToString(); pants.AssetType = (int)AssetType.Clothing; pants.InvType = (int)InventoryType.Wearable; pants.Folder = clothingFolder.ID; pants.BasePermissions = (uint)PermissionMask.All; pants.CurrentPermissions = (uint)PermissionMask.All; pants.EveryOnePermissions = (uint)PermissionMask.All; pants.GroupPermissions = (uint)PermissionMask.All; pants.NextPermissions = (uint)PermissionMask.All; pants.Flags = (uint)WearableType.Pants; m_InventoryService.AddItem(pants); if (m_AvatarService != null) { m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default avatar entries for {0}", principalID); AvatarWearable[] wearables = new AvatarWearable[6]; wearables[AvatarWearable.EYES] = new AvatarWearable(eyes.ID, eyes.AssetID); wearables[AvatarWearable.BODY] = new AvatarWearable(shape.ID, shape.AssetID); wearables[AvatarWearable.SKIN] = new AvatarWearable(skin.ID, skin.AssetID); wearables[AvatarWearable.HAIR] = new AvatarWearable(hair.ID, hair.AssetID); wearables[AvatarWearable.SHIRT] = new AvatarWearable(shirt.ID, shirt.AssetID); wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID); AvatarAppearance ap = new AvatarAppearance(); for (int i = 0; i < 6; i++) { ap.SetWearable(i, wearables[i]); } m_AvatarService.SetAppearance(principalID, ap); } }
public void CacheWearableData(UUID principalID, AvatarWearable wearable) { if (!m_enableCacheBakedTextures) { IAssetService service = m_registry.RequestModuleInterface<IAssetService>(); if (service != null) { //Remove the old baked textures then from the DB as we don't want to keep them around foreach (UUID texture in wearable.GetItems().Values) { service.Delete(texture.ToString()); } } return; } wearable.MaxItems = 0; //Unlimited items AvatarBaseData baseData = new AvatarBaseData(); AvatarBaseData[] av = m_CacheDatabase.Get("PrincipalID", principalID.ToString()); foreach (AvatarBaseData abd in av) { //If we have one already made, keep what is already there if (abd.Data["Name"] == "CachedWearables") { baseData = abd; OSDArray array = (OSDArray)OSDParser.DeserializeJson(abd.Data["Value"]); AvatarWearable w = new AvatarWearable(); w.MaxItems = 0; //Unlimited items w.Unpack(array); foreach (KeyValuePair<UUID, UUID> kvp in w.GetItems()) { wearable.Add(kvp.Key, kvp.Value); } } } //If we don't have one, set it up for saving a new one if (baseData.Data == null) { baseData.PrincipalID = principalID; baseData.Data = new Dictionary<string, string>(); baseData.Data.Add("Name", "CachedWearables"); } baseData.Data["Value"] = OSDParser.SerializeJsonString(wearable.Pack()); try { bool store = m_CacheDatabase.Store(baseData); if (!store) { m_log.Warn("[AvatarService]: Issue saving the cached wearables to the database."); } } catch { } }
private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance, InventoryFolderBase destinationFolder, UUID agentid, OSDMap itemsMap, out List <InventoryItemBase> items) { if (destinationFolder == null) { throw new Exception("Cannot locate folder(s)"); } items = new List <InventoryItemBase>(); List <InventoryItemBase> litems = new List <InventoryItemBase>(); foreach (KeyValuePair <string, OSD> kvp in itemsMap) { InventoryItemBase item = new InventoryItemBase(); item.FromOSD((OSDMap)kvp.Value); MainConsole.Instance.Info("[AvatarArchive]: Loading item " + item.ID.ToString()); litems.Add(item); } // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i = 0; i < wearables.Length; i++) { AvatarWearable wearable = wearables[i]; for (int ii = 0; ii < wearable.Count; ii++) { if (wearable[ii].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = InventoryService.GetItem(UUID.Zero, wearable[ii].ItemID); if (item == null) { //Attempt to get from the map if it doesn't already exist on the grid item = litems.First((itm) => itm.ID == wearable[ii].ItemID); } if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder .ID, false, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Wear item AvatarWearable newWearable = new AvatarWearable(); newWearable.Wear(destinationItem.ID, destinationItem.AssetID); avatarAppearance.SetWearable(i, newWearable); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[ii].ItemID, destinationFolder.ID); } } } } // Attachments List <AvatarAttachment> attachments = avatarAppearance.GetAttachments(); foreach (AvatarAttachment attachment in attachments) { int attachpoint = attachment.AttachPoint; UUID itemID = attachment.ItemID; if (itemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = InventoryService.GetItem(UUID.Zero, itemID); if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder.ID, false, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } return(avatarAppearance); }
private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance, InventoryFolderBase destinationFolder, UUID agentid, out List <InventoryItemBase> items) { if (destinationFolder == null) { throw new Exception("Cannot locate folder(s)"); } items = new List <InventoryItemBase>(); // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i = 0; i < wearables.Length; i++) { AvatarWearable wearable = wearables[i]; for (int ii = 0; ii < wearable.Count; ii++) { if (wearable[ii].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = new InventoryItemBase(wearable[ii].ItemID); item = InventoryService.GetItem(item); if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder.ID, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Wear item AvatarWearable newWearable = new AvatarWearable(); newWearable.Wear(destinationItem.ID, wearable[ii].AssetID); avatarAppearance.SetWearable(i, newWearable); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[ii].ItemID, destinationFolder.ID); } } } } // Attachments List <AvatarAttachment> attachments = avatarAppearance.GetAttachments(); foreach (AvatarAttachment attachment in attachments) { int attachpoint = attachment.AttachPoint; UUID itemID = attachment.ItemID; if (itemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = new InventoryItemBase(itemID, source); item = InventoryService.GetItem(item); if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder.ID, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } return(avatarAppearance); }
private void FixItemIDs(UUID oldID, InventoryItemBase item, AvatarAppearance appearance) { //Fix the IDs AvatarWearable[] wearables = new AvatarWearable[appearance.Wearables.Length]; appearance.Wearables.CopyTo(wearables, 0); for (int a = 0; a < wearables.Length; a++) { for (int i = 0; i < wearables[a].Count; i++) { if (wearables[a][i].ItemID == oldID) { //Fix the ItemID AvatarWearable w = new AvatarWearable(); w.Unpack((OSDArray)wearables[a].Pack()); UUID assetID = w.GetAsset(oldID); w.RemoveItem(oldID); w.Add(item.ID, assetID); appearance.SetWearable(a, w); return; } } } }
private AvatarAppearance ConvertXMLToAvatarAppearance(List<string> file, out List<UUID> AttachmentIDs, out List<string> AttachmentPoints, out List<string> AttachmentAsset, out string FolderNameToPlaceAppearanceIn) { AvatarAppearance appearance = new AvatarAppearance(); List<string> newFile = new List<string>(); foreach (string line in file) { string newLine = line.TrimStart('<'); newFile.Add(newLine.TrimEnd('>')); } appearance.AvatarHeight = Convert.ToInt32(newFile[1]); appearance.BodyAsset = new UUID(newFile[2]); appearance.BodyItem = new UUID(newFile[3]); appearance.EyesAsset = new UUID(newFile[4]); appearance.EyesItem = new UUID(newFile[5]); appearance.GlovesAsset = new UUID(newFile[6]); appearance.GlovesItem = new UUID(newFile[7]); appearance.HairAsset = new UUID(newFile[8]); appearance.HairItem = new UUID(newFile[9]); //Skip Hip Offset appearance.JacketAsset = new UUID(newFile[11]); appearance.JacketItem = new UUID(newFile[12]); appearance.Owner = new UUID(newFile[13]); appearance.PantsAsset = new UUID(newFile[14]); appearance.PantsItem = new UUID(newFile[15]); appearance.Serial = Convert.ToInt32(newFile[16]); appearance.ShirtAsset = new UUID(newFile[17]); appearance.ShirtItem = new UUID(newFile[18]); appearance.ShoesAsset = new UUID(newFile[19]); appearance.ShoesItem = new UUID(newFile[20]); appearance.SkinAsset = new UUID(newFile[21]); appearance.SkinItem = new UUID(newFile[22]); appearance.SkirtAsset = new UUID(newFile[23]); appearance.SkirtItem = new UUID(newFile[24]); appearance.SocksAsset = new UUID(newFile[25]); appearance.SocksItem = new UUID(newFile[26]); //appearance.Texture = new Primitive.TextureEntry(newFile[27],); appearance.UnderPantsAsset = new UUID(newFile[27]); appearance.UnderPantsItem = new UUID(newFile[28]); appearance.UnderShirtAsset = new UUID(newFile[29]); appearance.UnderShirtItem = new UUID(newFile[30]); FolderNameToPlaceAppearanceIn = newFile[31]; Byte[] bytes = new byte[218]; int i = 0; while (i <= 31) { newFile.RemoveAt(0); //Clear out the already processed parts i++; } i = 0; if (newFile[0] == "VisualParams") { foreach (string partLine in newFile) { if (partLine.StartsWith("/VP")) { string newpartLine = ""; newpartLine = partLine.Replace("/VP", ""); bytes[i] = Convert.ToByte(newpartLine); i++; } } } appearance.VisualParams = bytes; List<string> WearableAsset = new List<string>(); List<string> WearableItem = new List<string>(); string texture = ""; AttachmentIDs = new List<UUID>(); AttachmentPoints = new List<string>(); AttachmentAsset = new List<string>(); foreach (string partLine in newFile) { if (partLine.StartsWith("WA")) { string newpartLine = ""; newpartLine = partLine.Replace("WA", ""); WearableAsset.Add(newpartLine); } if (partLine.StartsWith("WI")) { string newpartLine = ""; newpartLine = partLine.Replace("WI", ""); WearableItem.Add(newpartLine); } if (partLine.StartsWith("TEXTURE")) { string newpartLine = ""; newpartLine = partLine.Replace("TEXTURE", ""); texture = newpartLine; } if (partLine.StartsWith("AI")) { string newpartLine = ""; newpartLine = partLine.Replace("AI", ""); AttachmentIDs.Add(new UUID(newpartLine)); } if (partLine.StartsWith("AA")) { string newpartLine = ""; newpartLine = partLine.Replace("AA", ""); AttachmentAsset.Add(newpartLine); } if (partLine.StartsWith("AP")) { string newpartLine = ""; newpartLine = partLine.Replace("AP", ""); AttachmentPoints.Add(newpartLine); } } //byte[] textureBytes = Utils.StringToBytes(texture); //appearance.Texture = new Primitive.TextureEntry(textureBytes, 0, textureBytes.Length); AvatarWearable[] wearables = new AvatarWearable[13]; i = 0; foreach (string asset in WearableAsset) { AvatarWearable wearable = new AvatarWearable(new UUID(asset), new UUID(WearableItem[i])); wearables[i] = wearable; i++; } i = 0; foreach (string asset in AttachmentAsset) { appearance.SetAttachment(Convert.ToInt32(AttachmentPoints[i]), AttachmentIDs[i], new UUID(asset)); i++; } return appearance; }
// <summary> // </summary> // <param name=""></param> public AvatarData GetAvatar(UUID userID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUser" }, { "UserID", userID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean()) { OSDMap map = null; try { map = OSDParser.DeserializeJson(response["LLAppearance"].AsString()) as OSDMap; } catch { } if (map != null) { AvatarWearable[] wearables = new AvatarWearable[13]; wearables[0] = new AvatarWearable(map["ShapeItem"].AsUUID(), map["ShapeAsset"].AsUUID()); wearables[1] = new AvatarWearable(map["SkinItem"].AsUUID(), map["SkinAsset"].AsUUID()); wearables[2] = new AvatarWearable(map["HairItem"].AsUUID(), map["HairAsset"].AsUUID()); wearables[3] = new AvatarWearable(map["EyesItem"].AsUUID(), map["EyesAsset"].AsUUID()); wearables[4] = new AvatarWearable(map["ShirtItem"].AsUUID(), map["ShirtAsset"].AsUUID()); wearables[5] = new AvatarWearable(map["PantsItem"].AsUUID(), map["PantsAsset"].AsUUID()); wearables[6] = new AvatarWearable(map["ShoesItem"].AsUUID(), map["ShoesAsset"].AsUUID()); wearables[7] = new AvatarWearable(map["SocksItem"].AsUUID(), map["SocksAsset"].AsUUID()); wearables[8] = new AvatarWearable(map["JacketItem"].AsUUID(), map["JacketAsset"].AsUUID()); wearables[9] = new AvatarWearable(map["GlovesItem"].AsUUID(), map["GlovesAsset"].AsUUID()); wearables[10] = new AvatarWearable(map["UndershirtItem"].AsUUID(), map["UndershirtAsset"].AsUUID()); wearables[11] = new AvatarWearable(map["UnderpantsItem"].AsUUID(), map["UnderpantsAsset"].AsUUID()); wearables[12] = new AvatarWearable(map["SkirtItem"].AsUUID(), map["SkirtAsset"].AsUUID()); AvatarAppearance appearance = new AvatarAppearance(); appearance.Wearables = wearables; appearance.AvatarHeight = (float)map["Height"].AsReal(); AvatarData avatar = new AvatarData(appearance); // Get attachments map = null; try { map = OSDParser.DeserializeJson(response["LLAttachments"].AsString()) as OSDMap; } catch { } if (map != null) { foreach (KeyValuePair <string, OSD> kvp in map) { avatar.Data[kvp.Key] = kvp.Value.AsString(); } } return(avatar); } else { m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID + ", LLAppearance is missing or invalid"); return(null); } } else { m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID + ": " + response["Message"].AsString()); } return(null); }
private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance, InventoryFolderBase destinationFolder) { if (destinationFolder == null) { throw new Exception("Cannot locate folder(s)"); } // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i = 0; i < wearables.Length; i++) { AvatarWearable wearable = wearables[i]; for (int ii = 0; ii < wearable.Count; ii++) { if (wearable[ii].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = new InventoryItemBase(wearable[ii].ItemID); item = InventoryService.GetItem(item); if (item != null) { InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination) { Name = item.Name, Description = item.Description, InvType = item.InvType, CreatorId = item.CreatorId, CreatorData = item.CreatorData, CreatorIdAsUuid = item.CreatorIdAsUuid, NextPermissions = item.NextPermissions, CurrentPermissions = item.CurrentPermissions, BasePermissions = item.BasePermissions, EveryOnePermissions = item.EveryOnePermissions, GroupPermissions = item.GroupPermissions, AssetType = item.AssetType, AssetID = item.AssetID, GroupID = item.GroupID, GroupOwned = item.GroupOwned, SalePrice = item.SalePrice, SaleType = item.SaleType, Flags = item.Flags, CreationDate = item.CreationDate, Folder = destinationFolder.ID }; if (InventoryService != null) { InventoryService.AddItem(destinationItem); } MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Wear item AvatarWearable newWearable = new AvatarWearable(); newWearable.Wear(destinationItem.ID, wearable[ii].AssetID); avatarAppearance.SetWearable(i, newWearable); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[ii].ItemID, destinationFolder.ID); } } } } // Attachments List <AvatarAttachment> attachments = avatarAppearance.GetAttachments(); foreach (AvatarAttachment attachment in attachments) { int attachpoint = attachment.AttachPoint; UUID itemID = attachment.ItemID; if (itemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = new InventoryItemBase(itemID, source); item = InventoryService.GetItem(item); if (item != null) { InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination) { Name = item.Name, Description = item.Description, InvType = item.InvType, CreatorId = item.CreatorId, CreatorData = item.CreatorData, CreatorIdAsUuid = item.CreatorIdAsUuid, NextPermissions = item.NextPermissions, CurrentPermissions = item.CurrentPermissions, BasePermissions = item.BasePermissions, EveryOnePermissions = item.EveryOnePermissions, GroupPermissions = item.GroupPermissions, AssetType = item.AssetType, AssetID = item.AssetID, GroupID = item.GroupID, GroupOwned = item.GroupOwned, SalePrice = item.SalePrice, SaleType = item.SaleType, Flags = item.Flags, CreationDate = item.CreationDate, Folder = destinationFolder.ID }; if (InventoryService != null) { InventoryService.AddItem(destinationItem); } MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } return(avatarAppearance); }
private void OnAppearanceUpdateTimer(object source, ElapsedEventArgs e) { List <AppearanceUpdateRequest> readyRequests = new List <AppearanceUpdateRequest>(); lock (_pendingUpdates) { foreach (AppearanceUpdateRequest req in _pendingUpdates.Values) { if (DateTime.Now - req.RequestTime >= TimeSpan.FromSeconds(3.0)) { readyRequests.Add(req); } } foreach (AppearanceUpdateRequest req in readyRequests) { _pendingUpdates.Remove(req.UserId); } if (_pendingUpdates.Count == 0) { _appearanceUpdateTimer.Enabled = false; } } foreach (AppearanceUpdateRequest upd in readyRequests) { bool appearanceValid = true; // Sanity checking the update List <AvatarWearable> wearables = upd.Appearance.GetWearables(); foreach (AvatarWearable wearable in wearables) { if (AvatarWearable.IsRequiredWearable(wearable.WearableType) && (wearable.ItemID == UUID.Zero)) { m_log.ErrorFormat( "[APPEARANCE]: Refusing to commit avatar appearance for user {0} because required wearable is zero'd", upd.UserId.ToString()); appearanceValid = false; break; } } //Don't allow saving of appearances to the avatarappearance table for bots if (upd.Appearance.IsBotAppearance) { appearanceValid = false; } if (appearanceValid == true) { if (upd.CallBack != null) { upd.CallBack(); } m_scene.CommsManager.AvatarService.UpdateUserAppearance(upd.UserId, upd.Appearance); if (upd.BakedTextures != null && upd.BakedTextures.Count > 0) { m_scene.CommsManager.AvatarService.SetCachedBakedTextures(upd.BakedTextures); } } } }
/// <summary> /// Update what the avatar is wearing using an item from their inventory. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { IClientAPI clientView = (IClientAPI)sender; ScenePresence avatar = m_scene.GetScenePresence(clientView.AgentId); if (avatar == null) { m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); return; } CachedUserInfo profile = m_scene.CommsManager.UserService.GetUserDetails(clientView.AgentId); if (profile != null) { // we need to clean out the existing textures AvatarAppearance appearance = avatar.Appearance; avatar.Appearance.ResetAppearance(); List <AvatarWearable> wearables = new List <AvatarWearable>(); lock (_currentlyWaitingCOFBuilds) { //Check to see whether the client can manage itself if (_cofSyncEnabled && !_viewer2Users.Contains(clientView.AgentId)) { foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) { wearables.Add(new AvatarWearable(wear.Type, wear.ItemID, UUID.Zero)); AvatarWearable oldWearable = appearance.GetWearableOfType(wear.Type); if (wear.ItemID != UUID.Zero) { if (oldWearable == null || oldWearable.ItemID == UUID.Zero || wear.ItemID != oldWearable.ItemID) { bool add = false; Dictionary <UUID, BuildCOF> waitingCOFs = new Dictionary <UUID, BuildCOF>(); if ((add = !_currentlyWaitingCOFBuilds.TryGetValue(clientView.AgentId, out waitingCOFs))) { waitingCOFs = new Dictionary <UUID, BuildCOF>(); } //Make sure that the new item is added if (waitingCOFs.ContainsKey(wear.ItemID)) { BuildCOF cof = waitingCOFs[wear.ItemID]; cof.SetWearableToLookFor(wear.ItemID, m_scene, clientView.AgentId, true); if (cof.Finished()) { waitingCOFs.Remove(wear.ItemID); } } else { BuildCOF cof = new BuildCOF(ClearWaitingCOF); cof.SetWearableToLookFor(wear.ItemID, m_scene, clientView.AgentId, true); waitingCOFs.Add(wear.ItemID, cof); } if (add) { _currentlyWaitingCOFBuilds.Add(clientView.AgentId, waitingCOFs); } } if (oldWearable != null && oldWearable.ItemID != UUID.Zero && wear.ItemID != oldWearable.ItemID) { bool add = false; Dictionary <UUID, BuildCOF> waitingCOFs = new Dictionary <UUID, BuildCOF>(); if ((add = !_currentlyWaitingCOFBuilds.TryGetValue(clientView.AgentId, out waitingCOFs))) { waitingCOFs = new Dictionary <UUID, BuildCOF>(); } //Check for removal of old item if (waitingCOFs.ContainsKey(oldWearable.ItemID)) { BuildCOF cof = waitingCOFs[oldWearable.ItemID]; cof.SetWearableToLookFor(oldWearable.ItemID, m_scene, clientView.AgentId, false); if (cof.Finished()) { waitingCOFs.Remove(oldWearable.ItemID); } } else { BuildCOF cof = new BuildCOF(ClearWaitingCOF); cof.SetWearableToLookFor(oldWearable.ItemID, m_scene, clientView.AgentId, false); waitingCOFs.Add(oldWearable.ItemID, cof); } if (add) { _currentlyWaitingCOFBuilds.Add(clientView.AgentId, waitingCOFs); } } } else if (oldWearable != null && oldWearable.ItemID != UUID.Zero) { bool add = false; Dictionary <UUID, BuildCOF> waitingCOFs = new Dictionary <UUID, BuildCOF>(); if ((add = !_currentlyWaitingCOFBuilds.TryGetValue(clientView.AgentId, out waitingCOFs))) { waitingCOFs = new Dictionary <UUID, BuildCOF>(); } //Remove the item if it was just removed if (waitingCOFs.ContainsKey(oldWearable.ItemID)) { BuildCOF cof = waitingCOFs[oldWearable.ItemID]; cof.SetWearableToLookFor(oldWearable.ItemID, m_scene, clientView.AgentId, false); if (cof.Finished()) { waitingCOFs.Remove(oldWearable.ItemID); } } else { BuildCOF cof = new BuildCOF(ClearWaitingCOF); cof.SetWearableToLookFor(oldWearable.ItemID, m_scene, clientView.AgentId, false); waitingCOFs.Add(oldWearable.ItemID, cof); } if (add) { _currentlyWaitingCOFBuilds.Add(clientView.AgentId, waitingCOFs); } } } } else { foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) { wearables.Add(new AvatarWearable(wear.Type, wear.ItemID, UUID.Zero)); } } } // Wearables are a stack. The entries we have represent the current "top" stack state. Apply them SetAppearanceAssets(profile, ref wearables, clientView); avatar.Appearance.SetWearables(wearables); this.UpdateDatabase(clientView.AgentId, avatar.Appearance, null, null); } else { m_log.WarnFormat("[APPEARANCE]: Cannot set wearables for {0}, no user profile found", clientView.Name); } }
private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance, InventoryFolderBase destinationFolder, UUID agentid, out List<InventoryItemBase> items) { if (destinationFolder == null) throw new Exception("Cannot locate folder(s)"); items = new List<InventoryItemBase>(); // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i = 0; i < wearables.Length; i++) { AvatarWearable wearable = wearables[i]; for (int ii = 0; ii < wearable.Count; ii++) { if (wearable[ii].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = InventoryService.GetItem(agentid, wearable[ii].ItemID); if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder .ID, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Wear item AvatarWearable newWearable = new AvatarWearable(); newWearable.Wear(destinationItem.ID, destinationItem.AssetID); avatarAppearance.SetWearable(i, newWearable); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[ii].ItemID, destinationFolder.ID); } } } } // Attachments List<AvatarAttachment> attachments = avatarAppearance.GetAttachments(); foreach (AvatarAttachment attachment in attachments) { int attachpoint = attachment.AttachPoint; UUID itemID = attachment.ItemID; if (itemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = InventoryService.GetItem(source, itemID); if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder.ID, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } return avatarAppearance; }
private AvatarAppearance ConvertXMLToAvatarAppearance(OSDMap map, out string FolderNameToPlaceAppearanceIn) { AvatarAppearance appearance = new AvatarAppearance(); appearance.AvatarHeight = (float)map["AvatarHeight"].AsReal(); appearance.BodyAsset = map["BodyAsset"].AsUUID(); appearance.BodyItem = map["BodyItem"].AsUUID(); appearance.EyesAsset = map["EyesAsset"].AsUUID(); appearance.EyesItem = map["EyesItem"].AsUUID(); appearance.GlovesAsset = map["GlovesAsset"].AsUUID(); appearance.GlovesItem = map["GlovesItem"].AsUUID(); appearance.HairAsset = map["HairAsset"].AsUUID(); appearance.HairItem = map["HairItem"].AsUUID(); //Skip Hip Offset appearance.JacketAsset = map["JacketAsset"].AsUUID(); appearance.JacketItem = map["JacketItem"].AsUUID(); appearance.Owner = map["Owner"].AsUUID(); appearance.PantsAsset = map["PantsAsset"].AsUUID(); appearance.PantsItem = map["PantsItem"].AsUUID(); appearance.Serial = map["Serial"].AsInteger(); appearance.ShirtAsset = map["ShirtAsset"].AsUUID(); appearance.ShirtItem = map["ShirtItem"].AsUUID(); appearance.ShoesAsset = map["ShoesAsset"].AsUUID(); appearance.ShoesItem = map["ShoesItem"].AsUUID(); appearance.SkinAsset = map["SkinAsset"].AsUUID(); appearance.SkinItem = map["SkinItem"].AsUUID(); appearance.SkirtAsset = map["SkirtAsset"].AsUUID(); appearance.SkirtItem = map["SkirtItem"].AsUUID(); appearance.SocksAsset = map["SocksAsset"].AsUUID(); appearance.SocksItem = map["SocksItem"].AsUUID(); appearance.UnderPantsAsset = map["UnderPantsAsset"].AsUUID(); appearance.UnderPantsItem = map["UnderPantsItem"].AsUUID(); appearance.UnderShirtAsset = map["UnderShirtAsset"].AsUUID(); appearance.UnderShirtItem = map["UnderShirtItem"].AsUUID(); appearance.TattooAsset = map["TattooAsset"].AsUUID(); appearance.TattooItem = map["TattooItem"].AsUUID(); appearance.AlphaAsset = map["AlphaAsset"].AsUUID(); appearance.AlphaItem = map["AlphaItem"].AsUUID(); FolderNameToPlaceAppearanceIn = map["FolderName"].AsString(); appearance.VisualParams = map["VisualParams"].AsBinary(); OSDArray wearables = (OSDArray)map["AvatarWearables"]; List<AvatarWearable> AvatarWearables = new List<AvatarWearable>(); foreach (OSD o in wearables) { OSDMap wearable = (OSDMap)o; AvatarWearable wear = new AvatarWearable(); wear.AssetID = wearable["Asset"].AsUUID(); wear.ItemID = wearable["Item"].AsUUID(); AvatarWearables.Add(wear); } appearance.Wearables = AvatarWearables.ToArray(); appearance.Texture = Primitive.TextureEntry.FromOSD(map["Texture"]); OSDArray attachmentsArray = (OSDArray)map["Attachments"]; foreach (OSD o in wearables) { OSDMap attachment = (OSDMap)o; UUID Asset = attachment["Asset"].AsUUID(); UUID Item = attachment["Item"].AsUUID(); int AttachmentPoint = attachment["Point"].AsInteger(); appearance.SetAttachment(AttachmentPoint, Item, Asset); } return appearance; }
private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance, InventoryFolderBase destinationFolder, UUID agentid, OSDMap itemsMap, out List<InventoryItemBase> items) { if (destinationFolder == null) throw new Exception("Cannot locate folder(s)"); items = new List<InventoryItemBase>(); List<InventoryItemBase> litems = new List<InventoryItemBase>(); foreach (KeyValuePair<string, OSD> kvp in itemsMap) { InventoryItemBase item = new InventoryItemBase(); item.FromOSD((OSDMap)kvp.Value); MainConsole.Instance.Info("[AvatarArchive]: Loading item " + item.ID.ToString()); litems.Add(item); } // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i = 0; i < wearables.Length; i++) { AvatarWearable wearable = wearables[i]; for (int ii = 0; ii < wearable.Count; ii++) { if (wearable[ii].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = InventoryService.GetItem(UUID.Zero, wearable[ii].ItemID); if (item == null) { //Attempt to get from the map if it doesn't already exist on the grid item = litems.First((itm) => itm.ID == wearable[ii].ItemID); } if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder .ID, false, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Wear item AvatarWearable newWearable = new AvatarWearable(); newWearable.Wear(destinationItem.ID, destinationItem.AssetID); avatarAppearance.SetWearable(i, newWearable); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[ii].ItemID, destinationFolder.ID); } } } } // Attachments List<AvatarAttachment> attachments = avatarAppearance.GetAttachments(); foreach (AvatarAttachment attachment in attachments) { int attachpoint = attachment.AttachPoint; UUID itemID = attachment.ItemID; if (itemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = InventoryService.GetItem(UUID.Zero, itemID); if (item != null) { InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination, destination, item, destinationFolder.ID, false, false); items.Add(destinationItem); MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } else { MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } return avatarAppearance; }
public AvatarAppearance ToAvatarAppearance() { AvatarAppearance appearance = new AvatarAppearance(); if (Data.Count == 0) { return(appearance); } appearance.ClearWearables(); try { if (Data.ContainsKey("Serial")) { appearance.Serial = Int32.Parse(Data["Serial"]); } if (Data.ContainsKey("AvatarHeight")) { float h = float.Parse(Data["AvatarHeight"]); if (h == 0f) { h = 1.9f; } appearance.SetSize(new Vector3(0.45f, 0.6f, h)); } // Legacy Wearables if (Data.ContainsKey("BodyItem")) { appearance.Wearables[AvatarWearable.BODY].Wear( UUID.Parse(Data["BodyItem"]), UUID.Parse(Data["BodyAsset"])); } if (Data.ContainsKey("SkinItem")) { appearance.Wearables[AvatarWearable.SKIN].Wear( UUID.Parse(Data["SkinItem"]), UUID.Parse(Data["SkinAsset"])); } if (Data.ContainsKey("HairItem")) { appearance.Wearables[AvatarWearable.HAIR].Wear( UUID.Parse(Data["HairItem"]), UUID.Parse(Data["HairAsset"])); } if (Data.ContainsKey("EyesItem")) { appearance.Wearables[AvatarWearable.EYES].Wear( UUID.Parse(Data["EyesItem"]), UUID.Parse(Data["EyesAsset"])); } if (Data.ContainsKey("ShirtItem")) { appearance.Wearables[AvatarWearable.SHIRT].Wear( UUID.Parse(Data["ShirtItem"]), UUID.Parse(Data["ShirtAsset"])); } if (Data.ContainsKey("PantsItem")) { appearance.Wearables[AvatarWearable.PANTS].Wear( UUID.Parse(Data["PantsItem"]), UUID.Parse(Data["PantsAsset"])); } if (Data.ContainsKey("ShoesItem")) { appearance.Wearables[AvatarWearable.SHOES].Wear( UUID.Parse(Data["ShoesItem"]), UUID.Parse(Data["ShoesAsset"])); } if (Data.ContainsKey("SocksItem")) { appearance.Wearables[AvatarWearable.SOCKS].Wear( UUID.Parse(Data["SocksItem"]), UUID.Parse(Data["SocksAsset"])); } if (Data.ContainsKey("JacketItem")) { appearance.Wearables[AvatarWearable.JACKET].Wear( UUID.Parse(Data["JacketItem"]), UUID.Parse(Data["JacketAsset"])); } if (Data.ContainsKey("GlovesItem")) { appearance.Wearables[AvatarWearable.GLOVES].Wear( UUID.Parse(Data["GlovesItem"]), UUID.Parse(Data["GlovesAsset"])); } if (Data.ContainsKey("UnderShirtItem")) { appearance.Wearables[AvatarWearable.UNDERSHIRT].Wear( UUID.Parse(Data["UnderShirtItem"]), UUID.Parse(Data["UnderShirtAsset"])); } if (Data.ContainsKey("UnderPantsItem")) { appearance.Wearables[AvatarWearable.UNDERPANTS].Wear( UUID.Parse(Data["UnderPantsItem"]), UUID.Parse(Data["UnderPantsAsset"])); } if (Data.ContainsKey("SkirtItem")) { appearance.Wearables[AvatarWearable.SKIRT].Wear( UUID.Parse(Data["SkirtItem"]), UUID.Parse(Data["SkirtAsset"])); } if (Data.ContainsKey("VisualParams")) { string[] vps = Data["VisualParams"].Split(new char[] { ',' }); byte[] binary = new byte[vps.Length]; for (int i = 0; i < vps.Length; i++) { binary[i] = (byte)Convert.ToInt32(vps[i]); } appearance.VisualParams = binary; } AvatarWearable[] wearables = appearance.Wearables; int currentLength = wearables.Length; foreach (KeyValuePair <string, string> _kvp in Data) { // New style wearables if (_kvp.Key.StartsWith("Wearable ") && _kvp.Key.Length > 9) { string wearIndex = _kvp.Key.Substring(9); string[] wearIndices = wearIndex.Split(new char[] { ':' }); int index = Convert.ToInt32(wearIndices[0]); string[] ids = _kvp.Value.Split(new char[] { ':' }); UUID itemID = new UUID(ids[0]); UUID assetID = new UUID(ids[1]); if (index >= currentLength) { Array.Resize(ref wearables, index + 1); for (int i = currentLength; i < wearables.Length; i++) { wearables[i] = new AvatarWearable(); } currentLength = wearables.Length; } wearables[index].Add(itemID, assetID); continue; } // Attachments if (_kvp.Key.StartsWith("_ap_") && _kvp.Key.Length > 4) { string pointStr = _kvp.Key.Substring(4); int point = 0; if (Int32.TryParse(pointStr, out point)) { List <string> idList = new List <string>(_kvp.Value.Split(new char[] { ',' })); appearance.SetAttachment(point, UUID.Zero, UUID.Zero); foreach (string id in idList) { UUID uuid = UUID.Zero; if (UUID.TryParse(id, out uuid)) { appearance.SetAttachment(point | 0x80, uuid, UUID.Zero); } } } } } if (appearance.Wearables[AvatarWearable.BODY].Count == 0) { appearance.Wearables[AvatarWearable.BODY].Wear( AvatarWearable.DefaultWearables[ AvatarWearable.BODY][0]); } if (appearance.Wearables[AvatarWearable.SKIN].Count == 0) { appearance.Wearables[AvatarWearable.SKIN].Wear( AvatarWearable.DefaultWearables[ AvatarWearable.SKIN][0]); } if (appearance.Wearables[AvatarWearable.HAIR].Count == 0) { appearance.Wearables[AvatarWearable.HAIR].Wear( AvatarWearable.DefaultWearables[ AvatarWearable.HAIR][0]); } if (appearance.Wearables[AvatarWearable.EYES].Count == 0) { appearance.Wearables[AvatarWearable.EYES].Wear( AvatarWearable.DefaultWearables[ AvatarWearable.EYES][0]); } } catch { // We really should report something here, returning null // will at least break the wrapper return(null); } return(appearance); }
private void LoadAssets(OSDMap assets, AvatarAppearance appearance) { foreach (KeyValuePair<string, OSD> kvp in assets) { UUID AssetID = UUID.Parse(kvp.Key); OSDMap assetMap = (OSDMap)kvp.Value; AssetBase asset = AssetService.Get(AssetID.ToString()); m_log.Info("[AvatarArchive]: Loading asset " + AssetID.ToString()); if (asset == null) //Don't overwrite { asset = LoadAssetBase(assetMap); UUID oldassetID = asset.ID; UUID newAssetID = AssetService.Store(asset); asset.ID = newAssetID; //Fix the IDs AvatarWearable[] wearables = new AvatarWearable[appearance.Wearables.Length]; appearance.Wearables.CopyTo(wearables, 0); for (int a = 0; a < wearables.Length; a++) { for (int i = 0; i < wearables[a].Count; i++) { if (wearables[a][i].AssetID == oldassetID) { //Fix the ItemID AvatarWearable w = wearables[a]; UUID itemID = w.GetItem(oldassetID); w.RemoveItem(oldassetID); w.Add(itemID, newAssetID); appearance.SetWearable(a, w); break; } } } } } }
/// <summary> /// Tell the Avatar Service about these baked textures and items /// </summary> /// <param name = "sp"></param> /// <param name = "textureEntry"></param> /// <param name = "wearables"></param> private void CacheWearableData(IScenePresence sp, Primitive.TextureEntry textureEntry, WearableCache[] wearables) { if (textureEntry == null || wearables.Length == 0) return; AvatarWearable cachedWearable = new AvatarWearable {MaxItems = 0}; //Unlimited items #if (!ISWIN) foreach (WearableCache item in wearables) { if (textureEntry.FaceTextures[item.TextureIndex] != null) { cachedWearable.Add(item.CacheID, textureEntry.FaceTextures[item.TextureIndex].TextureID); } } #else foreach (WearableCache item in wearables.Where(item => textureEntry.FaceTextures[item.TextureIndex] != null)) { cachedWearable.Add(item.CacheID, textureEntry.FaceTextures[item.TextureIndex].TextureID); } #endif m_scene.AvatarService.CacheWearableData(sp.UUID, cachedWearable); }
private void HandleCheckWearablesCommand(string module, string[] cmd) { if (cmd.Length != 4) { MainConsole.Instance.Output("Usage: wearables check <first-name> <last-name>"); return; } string firstname = cmd[2]; string lastname = cmd[3]; StringBuilder sb = new StringBuilder(); UuidGatherer uuidGatherer = new UuidGatherer(m_scenes[0].AssetService); lock (m_scenes) { foreach (Scene scene in m_scenes) { ScenePresence sp = scene.GetScenePresence(firstname, lastname); if (sp != null && !sp.IsChildAgent) { sb.AppendFormat("Wearables checks for {0}\n\n", sp.Name); AvatarWearable[] wearables = sp.Appearance.Wearables; if (wearables.Length == 0) { MainConsole.Instance.Output("avatar has no wearables"); return; } for (int i = 0; i < wearables.Length; i++) { AvatarWearable aw = wearables[i]; sb.Append(Enum.GetName(typeof(WearableType), i)); sb.Append("\n"); if (aw.Count > 0) { for (int j = 0; j < aw.Count; j++) { WearableItem wi = aw[j]; ConsoleDisplayList cdl = new ConsoleDisplayList(); cdl.Indent = 2; cdl.AddRow("Item UUID", wi.ItemID); cdl.AddRow("Assets", ""); sb.Append(cdl.ToString()); uuidGatherer.AddForInspection(wi.AssetID); uuidGatherer.GatherAll(); string[] assetStrings = Array.ConvertAll <UUID, string>(uuidGatherer.GatheredUuids.Keys.ToArray(), u => u.ToString()); bool[] existChecks = scene.AssetService.AssetsExist(assetStrings); ConsoleDisplayTable cdt = new ConsoleDisplayTable(); cdt.Indent = 4; cdt.AddColumn("Type", 10); cdt.AddColumn("UUID", ConsoleDisplayUtil.UuidSize); cdt.AddColumn("Found", 5); for (int k = 0; k < existChecks.Length; k++) { cdt.AddRow( (AssetType)uuidGatherer.GatheredUuids[new UUID(assetStrings[k])], assetStrings[k], existChecks[k] ? "yes" : "no"); } sb.Append(cdt.ToString()); sb.Append("\n"); } } else { sb.Append(" Empty\n"); } } } } } MainConsole.Instance.Output(sb.ToString()); }
/// <summary> /// This method is called by EstablishAppearance to do a copy all inventory items /// worn or attached to the Clothing inventory folder of the receiving avatar. /// In parallel the avatar wearables and attachments are updated. /// </summary> private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance) { // Get Clothing folder of receiver InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing); if (destinationFolder == null) { throw new Exception("Cannot locate folder(s)"); } // Missing destination folder? This should *never* be the case if (destinationFolder.Type != (short)FolderType.Clothing) { destinationFolder = new InventoryFolderBase(); destinationFolder.ID = UUID.Random(); destinationFolder.Name = "Clothing"; destinationFolder.Owner = destination; destinationFolder.Type = (short)AssetType.Clothing; destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID; destinationFolder.Version = 1; m_InventoryService.AddFolder(destinationFolder); // store base record m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0}", source); } // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; AvatarWearable wearable; for (int i = 0; i < wearables.Length; i++) { wearable = wearables[i]; if (wearable[0].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = m_InventoryService.GetItem(source, wearable[0].ItemID); if (item != null) { InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); destinationItem.Name = item.Name; destinationItem.Owner = destination; destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; destinationItem.CreatorData = item.CreatorData; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; destinationItem.BasePermissions = item.BasePermissions; destinationItem.EveryOnePermissions = item.EveryOnePermissions; destinationItem.GroupPermissions = item.GroupPermissions; destinationItem.AssetType = item.AssetType; destinationItem.AssetID = item.AssetID; destinationItem.GroupID = item.GroupID; destinationItem.GroupOwned = item.GroupOwned; destinationItem.SalePrice = item.SalePrice; destinationItem.SaleType = item.SaleType; destinationItem.Flags = item.Flags; destinationItem.CreationDate = item.CreationDate; destinationItem.Folder = destinationFolder.ID; ApplyNextOwnerPermissions(destinationItem); m_InventoryService.AddItem(destinationItem); m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Wear item AvatarWearable newWearable = new AvatarWearable(); newWearable.Wear(destinationItem.ID, wearable[0].AssetID); avatarAppearance.SetWearable(i, newWearable); } else { m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID); } } } // Attachments List <AvatarAttachment> attachments = avatarAppearance.GetAttachments(); foreach (AvatarAttachment attachment in attachments) { int attachpoint = attachment.AttachPoint; UUID itemID = attachment.ItemID; if (itemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = m_InventoryService.GetItem(source, itemID); if (item != null) { InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); destinationItem.Name = item.Name; destinationItem.Owner = destination; destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; destinationItem.CreatorData = item.CreatorData; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; destinationItem.BasePermissions = item.BasePermissions; destinationItem.EveryOnePermissions = item.EveryOnePermissions; destinationItem.GroupPermissions = item.GroupPermissions; destinationItem.AssetType = item.AssetType; destinationItem.AssetID = item.AssetID; destinationItem.GroupID = item.GroupID; destinationItem.GroupOwned = item.GroupOwned; destinationItem.SalePrice = item.SalePrice; destinationItem.SaleType = item.SaleType; destinationItem.Flags = item.Flags; destinationItem.CreationDate = item.CreationDate; destinationItem.Folder = destinationFolder.ID; ApplyNextOwnerPermissions(destinationItem); m_InventoryService.AddItem(destinationItem); m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); m_log.DebugFormat("[USER ACCOUNT SERVICE]: Attached {0}", destinationItem.ID); } else { m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } }