/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args) { // DEBUG ON m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data"); // DEBUG OFF if (args.ContainsKey("region_id")) UUID.TryParse(args["region_id"].AsString(), out RegionID); if (args["circuit_code"] != null) UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); if (args["agent_uuid"] != null) AgentID = args["agent_uuid"].AsUUID(); if (args["session_uuid"] != null) SessionID = args["session_uuid"].AsUUID(); if (args["position"] != null) Vector3.TryParse(args["position"].AsString(), out Position); if (args["velocity"] != null) Vector3.TryParse(args["velocity"].AsString(), out Velocity); if (args["center"] != null) Vector3.TryParse(args["center"].AsString(), out Center); if (args["size"] != null) Vector3.TryParse(args["size"].AsString(), out Size); if (args["at_axis"] != null) Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); if (args["left_axis"] != null) Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); if (args["up_axis"] != null) Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); if (args["changed_grid"] != null) ChangedGrid = args["changed_grid"].AsBoolean(); if (args["far"] != null) Far = (float)(args["far"].AsReal()); if (args["aspect"] != null) Aspect = (float)args["aspect"].AsReal(); if (args["throttles"] != null) Throttles = args["throttles"].AsBinary(); if (args["locomotion_state"] != null) UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); if (args["head_rotation"] != null) Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); if (args["body_rotation"] != null) Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); if (args["control_flags"] != null) UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); if (args["energy_level"] != null) EnergyLevel = (float)(args["energy_level"].AsReal()); //This IS checked later if (args["god_level"] != null) Byte.TryParse(args["god_level"].AsString(), out GodLevel); if (args["speed"] != null) float.TryParse(args["speed"].AsString(), out Speed); else Speed = 1; if (args["draw_distance"] != null) float.TryParse(args["draw_distance"].AsString(), out DrawDistance); else DrawDistance = 0; //Reset this to fix movement... since regions are being bad about this if (Speed == 0) Speed = 1; if (args["always_run"] != null) AlwaysRun = args["always_run"].AsBoolean(); if (args["sent_initial_wearables"] != null) SentInitialWearables = args["sent_initial_wearables"].AsBoolean(); else SentInitialWearables = false; if (args["prey_agent"] != null) PreyAgent = args["prey_agent"].AsUUID(); if (args["agent_access"] != null) Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); if (args["active_group_id"] != null) ActiveGroupID = args["active_group_id"].AsUUID(); if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups[i++] = new AgentGroupData((OSDMap)o); } } } if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims[i++] = new Animation((OSDMap)o); } } } //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); // AgentTextures = new UUID[textures.Count]; // int i = 0; // foreach (OSD o in textures) // AgentTextures[i++] = o.AsUUID(); //} Appearance = new AvatarAppearance(AgentID); // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) { byte[] rawtextures = args["texture_entry"].AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length); List<UUID> changed = new List<UUID>(); Appearance.SetTextureEntries(textures, out changed); } if (args["visual_params"] != null) Appearance.SetVisualParams(args["visual_params"].AsBinary()); if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); Appearance.SetWearable(i, awear); } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) Appearance = new AvatarAppearance(AgentID, (OSDMap)args["packed_appearance"]); // DEBUG ON else m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); // DEBUG OFF if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) CallbackURI = args["callback_uri"].AsString(); }
/// <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) { IInventoryService inventoryService = m_application.SceneManager.CurrentOrFirstScene.InventoryService; // Get Clothing folder of receiver InventoryFolderBase destinationFolder = inventoryService.GetFolderForType(destination, AssetType.Clothing); if (destinationFolder == null) throw new Exception("Cannot locate folder(s)"); // Missing destination folder? This should *never* be the case if (destinationFolder.Type != (short)AssetType.Clothing) { destinationFolder = new InventoryFolderBase(); destinationFolder.ID = UUID.Random(); destinationFolder.Name = "Clothing"; destinationFolder.Owner = destination; destinationFolder.Type = (short)AssetType.Clothing; destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID; destinationFolder.Version = 1; inventoryService.AddFolder(destinationFolder); // store base record m_log.ErrorFormat("[RADMIN]: 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 = new InventoryItemBase(wearable[0].ItemID, source); item = inventoryService.GetItem(item); 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.CreatorIdAsUuid = item.CreatorIdAsUuid; 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_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem); m_log.DebugFormat("[RADMIN]: 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("[RADMIN]: 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 = new InventoryItemBase(itemID, source); item = inventoryService.GetItem(item); 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.CreatorIdAsUuid = item.CreatorIdAsUuid; 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_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem); m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); // Attach item avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); m_log.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID); } else { m_log.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID); } } } }
/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) { //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); if (args.ContainsKey("region_id")) UUID.TryParse(args["region_id"].AsString(), out RegionID); if (args["circuit_code"] != null) UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); if (args["agent_uuid"] != null) AgentID = args["agent_uuid"].AsUUID(); if (args["session_uuid"] != null) SessionID = args["session_uuid"].AsUUID(); if (args["position"] != null) Vector3.TryParse(args["position"].AsString(), out Position); if (args["velocity"] != null) Vector3.TryParse(args["velocity"].AsString(), out Velocity); if (args["center"] != null) Vector3.TryParse(args["center"].AsString(), out Center); if (args["size"] != null) Vector3.TryParse(args["size"].AsString(), out Size); if (args["at_axis"] != null) Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); if (args["left_axis"] != null) Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); if (args["up_axis"] != null) Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); if (args.ContainsKey("wait_for_root") && args["wait_for_root"] != null) SenderWantsToWaitForRoot = args["wait_for_root"].AsBoolean(); if (args["far"] != null) Far = (float)(args["far"].AsReal()); if (args["aspect"] != null) Aspect = (float)args["aspect"].AsReal(); if (args["throttles"] != null) Throttles = args["throttles"].AsBinary(); if (args["locomotion_state"] != null) UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); if (args["head_rotation"] != null) Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); if (args["body_rotation"] != null) Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); if (args["control_flags"] != null) UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); if (args["energy_level"] != null) EnergyLevel = (float)(args["energy_level"].AsReal()); if (args["god_level"] != null) Byte.TryParse(args["god_level"].AsString(), out GodLevel); if (args["always_run"] != null) AlwaysRun = args["always_run"].AsBoolean(); if (args["prey_agent"] != null) PreyAgent = args["prey_agent"].AsUUID(); if (args["agent_access"] != null) Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); if (args.ContainsKey("agent_cof") && args["agent_cof"] != null) agentCOF = args["agent_cof"].AsUUID(); if (args.ContainsKey("crossingflags") && args["crossingflags"] != null) CrossingFlags = (byte)args["crossingflags"].AsInteger(); if (args.ContainsKey("active_group_id") && args["active_group_id"] != null) ActiveGroupID = args["active_group_id"].AsUUID(); if (args.ContainsKey("active_group_name") && args["active_group_name"] != null) ActiveGroupName = args["active_group_name"].AsString(); if(args.ContainsKey("active_group_title") && args["active_group_title"] != null) ActiveGroupTitle = args["active_group_title"].AsString(); if (args.ContainsKey("groups") && (args["groups"] != null) && (args["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups[i++] = new AgentGroupData((OSDMap)o); } } } if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array)) { OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]); ChildrenCapSeeds = new Dictionary<ulong, string>(); foreach (OSD o in childrenSeeds) { if (o.Type == OSDType.Map) { ulong handle = 0; string seed = ""; OSDMap pair = (OSDMap)o; if (pair["handle"] != null) if (!UInt64.TryParse(pair["handle"].AsString(), out handle)) continue; if (pair["seed"] != null) seed = pair["seed"].AsString(); if (!ChildrenCapSeeds.ContainsKey(handle)) ChildrenCapSeeds.Add(handle, seed); } } } if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims[i++] = new Animation((OSDMap)o); } } } if (args["default_animation"] != null) { try { DefaultAnim = new Animation((OSDMap)args["default_animation"]); } catch { DefaultAnim = null; } } if (args["animation_state"] != null) { try { AnimState = new Animation((OSDMap)args["animation_state"]); } catch { AnimState = null; } } MovementAnimationOverRides.Clear(); if (args["movementAO"] != null && args["movementAO"].Type == OSDType.Array) { OSDArray AOs = (OSDArray)(args["movementAO"]); int count = AOs.Count; for (int i = 0; i < count; i++) { OSDMap ao = (OSDMap)AOs[i]; if (ao["state"] != null && ao["uuid"] != null) { string state = ao["state"].AsString(); UUID id = ao["uuid"].AsUUID(); MovementAnimationOverRides[state] = id; } } } if (args.ContainsKey("motion_state")) MotionState = (byte)args["motion_state"].AsInteger(); //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); // AgentTextures = new UUID[textures.Count]; // int i = 0; // foreach (OSD o in textures) // AgentTextures[i++] = o.AsUUID(); //} // packed_appearence should contain all appearance information if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) { m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance"); Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); } else { // if missing try the old pack method m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance, checking old method"); Appearance = new AvatarAppearance(); // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) { byte[] rawtextures = args["texture_entry"].AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length); Appearance.SetTextureEntries(textures); } if (args["visual_params"] != null) Appearance.SetVisualParams(args["visual_params"].AsBinary()); if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); Appearance.SetWearable(i, awear); } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove } /* moved above if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); else m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); */ if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) CallbackURI = args["callback_uri"].AsString(); // Attachment objects if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) { OSDArray attObjs = (OSDArray)(args["attach_objects"]); AttachmentObjects = new List<ISceneObject>(); AttachmentObjectStates = new List<string>(); foreach (OSD o in attObjs) { if (o.Type == OSDType.Map) { OSDMap info = (OSDMap)o; ISceneObject so = scene.DeserializeObject(info["sog"].AsString()); so.ExtraFromXmlString(info["extra"].AsString()); so.HasGroupChanged = info["modified"].AsBoolean(); AttachmentObjects.Add(so); AttachmentObjectStates.Add(info["state"].AsString()); } } } if (args["parent_part"] != null) ParentPart = args["parent_part"].AsUUID(); if (args["sit_offset"] != null) Vector3.TryParse(args["sit_offset"].AsString(), out SitOffset); }
/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) { //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); if (args.ContainsKey("region_id")) { UUID.TryParse(args["region_id"].AsString(), out RegionID); } if (args["circuit_code"] != null) { UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); } if (args["agent_uuid"] != null) { AgentID = args["agent_uuid"].AsUUID(); } if (args["session_uuid"] != null) { SessionID = args["session_uuid"].AsUUID(); } if (args["position"] != null) { Vector3.TryParse(args["position"].AsString(), out Position); } if (args["velocity"] != null) { Vector3.TryParse(args["velocity"].AsString(), out Velocity); } if (args["center"] != null) { Vector3.TryParse(args["center"].AsString(), out Center); } if (args["size"] != null) { Vector3.TryParse(args["size"].AsString(), out Size); } if (args["at_axis"] != null) { Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); } if (args["left_axis"] != null) { Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); } if (args["up_axis"] != null) { Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); } if (args.ContainsKey("wait_for_root") && args["wait_for_root"] != null) { SenderWantsToWaitForRoot = args["wait_for_root"].AsBoolean(); } if (args["far"] != null) { Far = (float)(args["far"].AsReal()); } if (args["aspect"] != null) { Aspect = (float)args["aspect"].AsReal(); } if (args["throttles"] != null) { Throttles = args["throttles"].AsBinary(); } if (args["locomotion_state"] != null) { UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); } if (args["head_rotation"] != null) { Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); } if (args["body_rotation"] != null) { Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); } if (args["control_flags"] != null) { UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); } if (args["energy_level"] != null) { EnergyLevel = (float)(args["energy_level"].AsReal()); } if (args["god_level"] != null) { Byte.TryParse(args["god_level"].AsString(), out GodLevel); } if (args["always_run"] != null) { AlwaysRun = args["always_run"].AsBoolean(); } if (args["prey_agent"] != null) { PreyAgent = args["prey_agent"].AsUUID(); } if (args["agent_access"] != null) { Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); } if (args["active_group_id"] != null) { ActiveGroupID = args["active_group_id"].AsUUID(); } if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups[i++] = new AgentGroupData((OSDMap)o); } } } if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array)) { OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]); ChildrenCapSeeds = new Dictionary <ulong, string>(); foreach (OSD o in childrenSeeds) { if (o.Type == OSDType.Map) { ulong handle = 0; string seed = ""; OSDMap pair = (OSDMap)o; if (pair["handle"] != null) { if (!UInt64.TryParse(pair["handle"].AsString(), out handle)) { continue; } } if (pair["seed"] != null) { seed = pair["seed"].AsString(); } if (!ChildrenCapSeeds.ContainsKey(handle)) { ChildrenCapSeeds.Add(handle, seed); } } } } if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims[i++] = new Animation((OSDMap)o); } } } if (args["default_animation"] != null) { try { DefaultAnim = new Animation((OSDMap)args["default_animation"]); } catch { DefaultAnim = null; } } if (args["animation_state"] != null) { try { AnimState = new Animation((OSDMap)args["animation_state"]); } catch { AnimState = null; } } MovementAnimationOverRides.Clear(); if (args["movementAO"] != null && args["movementAO"].Type == OSDType.Array) { OSDArray AOs = (OSDArray)(args["movementAO"]); int count = AOs.Count; for (int i = 0; i < count; i++) { OSDMap ao = (OSDMap)AOs[i]; if (ao["state"] != null && ao["uuid"] != null) { string state = ao["state"].AsString(); UUID id = ao["uuid"].AsUUID(); MovementAnimationOverRides[state] = id; } } } if (args.ContainsKey("motion_state")) { MotionState = (byte)args["motion_state"].AsInteger(); } //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); // AgentTextures = new UUID[textures.Count]; // int i = 0; // foreach (OSD o in textures) // AgentTextures[i++] = o.AsUUID(); //} // packed_appearence should contain all appearance information if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) { m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance"); Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); } else { // if missing try the old pack method m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance, checking old method"); Appearance = new AvatarAppearance(); // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) { byte[] rawtextures = args["texture_entry"].AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length); Appearance.SetTextureEntries(textures); } if (args["visual_params"] != null) { Appearance.SetVisualParams(args["visual_params"].AsBinary()); } if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); Appearance.SetWearable(i, awear); } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove } /* moved above * if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) * Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); * else * m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); */ if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) { CallbackURI = args["callback_uri"].AsString(); } // Attachment objects if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) { OSDArray attObjs = (OSDArray)(args["attach_objects"]); AttachmentObjects = new List <ISceneObject>(); AttachmentObjectStates = new List <string>(); foreach (OSD o in attObjs) { if (o.Type == OSDType.Map) { OSDMap info = (OSDMap)o; ISceneObject so = scene.DeserializeObject(info["sog"].AsString()); so.ExtraFromXmlString(info["extra"].AsString()); so.HasGroupChanged = info["modified"].AsBoolean(); AttachmentObjects.Add(so); AttachmentObjectStates.Add(info["state"].AsString()); } } } if (args["parent_part"] != null) { ParentPart = args["parent_part"].AsUUID(); } if (args["sit_offset"] != null) { Vector3.TryParse(args["sit_offset"].AsString(), out SitOffset); } }
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); } }
/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args) { // DEBUG ON m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data"); // DEBUG OFF if (args.ContainsKey("region_id")) { UUID.TryParse(args["region_id"].AsString(), out RegionID); } if (args["circuit_code"] != null) { UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); } if (args["agent_uuid"] != null) { AgentID = args["agent_uuid"].AsUUID(); } if (args["session_uuid"] != null) { SessionID = args["session_uuid"].AsUUID(); } if (args["position"] != null) { Vector3.TryParse(args["position"].AsString(), out Position); } if (args["velocity"] != null) { Vector3.TryParse(args["velocity"].AsString(), out Velocity); } if (args["center"] != null) { Vector3.TryParse(args["center"].AsString(), out Center); } if (args["size"] != null) { Vector3.TryParse(args["size"].AsString(), out Size); } if (args["at_axis"] != null) { Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); } if (args["left_axis"] != null) { Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); } if (args["up_axis"] != null) { Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); } if (args["changed_grid"] != null) { ChangedGrid = args["changed_grid"].AsBoolean(); } if (args["far"] != null) { Far = (float)(args["far"].AsReal()); } if (args["aspect"] != null) { Aspect = (float)args["aspect"].AsReal(); } if (args["throttles"] != null) { Throttles = args["throttles"].AsBinary(); } if (args["locomotion_state"] != null) { UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); } if (args["head_rotation"] != null) { Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); } if (args["body_rotation"] != null) { Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); } if (args["control_flags"] != null) { UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); } if (args["energy_level"] != null) { EnergyLevel = (float)(args["energy_level"].AsReal()); } if (args["god_level"] != null) { Byte.TryParse(args["god_level"].AsString(), out GodLevel); } if (args["always_run"] != null) { AlwaysRun = args["always_run"].AsBoolean(); } if (args["prey_agent"] != null) { PreyAgent = args["prey_agent"].AsUUID(); } if (args["agent_access"] != null) { Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); } if (args["active_group_id"] != null) { ActiveGroupID = args["active_group_id"].AsUUID(); } if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups[i++] = new AgentGroupData((OSDMap)o); } } } if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims[i++] = new Animation((OSDMap)o); } } } //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); // AgentTextures = new UUID[textures.Count]; // int i = 0; // foreach (OSD o in textures) // AgentTextures[i++] = o.AsUUID(); //} Appearance = new AvatarAppearance(AgentID); // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) { byte[] rawtextures = args["texture_entry"].AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length); Appearance.SetTextureEntries(textures); } if (args["visual_params"] != null) { Appearance.SetVisualParams(args["visual_params"].AsBinary()); } if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); Appearance.SetWearable(i, awear); } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) { Appearance = new AvatarAppearance(AgentID, (OSDMap)args["packed_appearance"]); } // DEBUG ON else { m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); } // DEBUG OFF if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) { CallbackURI = args["callback_uri"].AsString(); } }
/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args, IScene scene) { //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); if (args.ContainsKey("region_id")) UUID.TryParse(args["region_id"].AsString(), out RegionID); if (args["circuit_code"] != null) UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); if (args["agent_uuid"] != null) AgentID = args["agent_uuid"].AsUUID(); if (args["session_uuid"] != null) SessionID = args["session_uuid"].AsUUID(); if (args["position"] != null) Vector3.TryParse(args["position"].AsString(), out Position); if (args["velocity"] != null) Vector3.TryParse(args["velocity"].AsString(), out Velocity); if (args["center"] != null) Vector3.TryParse(args["center"].AsString(), out Center); if (args["size"] != null) Vector3.TryParse(args["size"].AsString(), out Size); if (args["at_axis"] != null) Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); if (args["left_axis"] != null) Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); if (args["up_axis"] != null) Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); if (args["changed_grid"] != null) ChangedGrid = args["changed_grid"].AsBoolean(); if (args["far"] != null) Far = (float)(args["far"].AsReal()); if (args["aspect"] != null) Aspect = (float)args["aspect"].AsReal(); if (args["throttles"] != null) Throttles = args["throttles"].AsBinary(); if (args["locomotion_state"] != null) UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); if (args["head_rotation"] != null) Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); if (args["body_rotation"] != null) Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); if (args["control_flags"] != null) UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); if (args["energy_level"] != null) EnergyLevel = (float)(args["energy_level"].AsReal()); if (args["god_level"] != null) Byte.TryParse(args["god_level"].AsString(), out GodLevel); if (args["always_run"] != null) AlwaysRun = args["always_run"].AsBoolean(); if (args["prey_agent"] != null) PreyAgent = args["prey_agent"].AsUUID(); if (args["agent_access"] != null) Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); if (args["active_group_id"] != null) ActiveGroupID = args["active_group_id"].AsUUID(); if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups[i++] = new AgentGroupData((OSDMap)o); } } } if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims[i++] = new Animation((OSDMap)o); } } } //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); // AgentTextures = new UUID[textures.Count]; // int i = 0; // foreach (OSD o in textures) // AgentTextures[i++] = o.AsUUID(); //} Appearance = new AvatarAppearance(); // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) { byte[] rawtextures = args["texture_entry"].AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length); Appearance.SetTextureEntries(textures); } if (args["visual_params"] != null) Appearance.SetVisualParams(args["visual_params"].AsBinary()); if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); Appearance.SetWearable(i,awear); } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); else m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) CallbackURI = args["callback_uri"].AsString(); // Attachment objects if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) { OSDArray attObjs = (OSDArray)(args["attach_objects"]); AttachmentObjects = new List<ISceneObject>(); AttachmentObjectStates = new List<string>(); foreach (OSD o in attObjs) { if (o.Type == OSDType.Map) { OSDMap info = (OSDMap)o; ISceneObject so = scene.DeserializeObject(info["sog"].AsString()); so.ExtraFromXmlString(info["extra"].AsString()); so.HasGroupChanged = info["modified"].AsBoolean(); AttachmentObjects.Add(so); AttachmentObjectStates.Add(info["state"].AsString()); } } } }
protected void CreateDefaultAppearanceEntries(UUID principalID) { m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.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, FolderType.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); } }
/// <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) { IInventoryService inventoryService = manager.CurrentOrFirstScene.InventoryService; // Get Clothing folder of receiver InventoryFolderBase destinationFolder = inventoryService.GetFolderForType (destination, InventoryType.Wearable, AssetType.Clothing); if (destinationFolder == null) throw new Exception("Cannot locate folder(s)"); // Missing destination folder? This should *never* be the case if (destinationFolder.Type != (short)AssetType.Clothing) { destinationFolder = new InventoryFolderBase { ID = UUID.Random(), Name = "Clothing", Owner = destination, Type = (short) AssetType.Clothing, ParentID = inventoryService.GetRootFolder(destination).ID, Version = 1 }; inventoryService.AddFolder(destinationFolder); // store base record MainConsole.Instance.ErrorFormat("[RADMIN] Created folder for destination {0}", source); } // Wearables AvatarWearable[] wearables = avatarAppearance.Wearables; for (int i = 0; i < wearables.Length; i++) { AvatarWearable wearable = wearables[i]; if (wearable[0].ItemID != UUID.Zero) { // Get inventory item and copy it InventoryItemBase item = new InventoryItemBase(wearable[0].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 }; ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>(); if (inventoryModule != null) inventoryModule.AddInventoryItem(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[0].AssetID); avatarAppearance.SetWearable(i, newWearable); } else { MainConsole.Instance.WarnFormat("[RADMIN]: 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 = 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 }; ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>(); if (inventoryModule != null) inventoryModule.AddInventoryItem(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); } } } }
/// <summary> /// Reads an avatar appearence from an active data reader /// </summary> /// <param name="reader">An active database reader</param> /// <returns>An avatar appearence</returns> private AvatarAppearance readAppearanceRow(IDataReader reader) { AvatarAppearance appearance = null; if (reader.Read()) { appearance = new AvatarAppearance(); appearance.Owner = new UUID(Convert.ToString(reader["owner"])); appearance.Serial = Convert.ToInt32(reader["serial"]); appearance.VisualParams = (byte[])reader["visual_params"]; if (reader["texture"] is DBNull) { appearance.Texture = new Primitive.TextureEntry(null); } else { appearance.Texture = new Primitive.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); } appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); // This handles the v1 style wearables list with a 1:1 relationship. appearance.SetWearable( new AvatarWearable( AvatarWearable.BODY, new UUID(Convert.ToString(reader["body_item"])), new UUID(Convert.ToString(reader["body_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.SKIN, new UUID(Convert.ToString(reader["skin_item"])), new UUID(Convert.ToString(reader["skin_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.HAIR, new UUID(Convert.ToString(reader["hair_item"])), new UUID(Convert.ToString(reader["hair_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.EYES, new UUID(Convert.ToString(reader["eyes_item"])), new UUID(Convert.ToString(reader["eyes_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.SHIRT, new UUID(Convert.ToString(reader["shirt_item"])), new UUID(Convert.ToString(reader["shirt_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.PANTS, new UUID(Convert.ToString(reader["pants_item"])), new UUID(Convert.ToString(reader["pants_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.SHOES, new UUID(Convert.ToString(reader["shoes_item"])), new UUID(Convert.ToString(reader["shoes_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.SOCKS, new UUID(Convert.ToString(reader["socks_item"])), new UUID(Convert.ToString(reader["socks_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.JACKET, new UUID(Convert.ToString(reader["jacket_item"])), new UUID(Convert.ToString(reader["jacket_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.GLOVES, new UUID(Convert.ToString(reader["gloves_item"])), new UUID(Convert.ToString(reader["gloves_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.UNDERSHIRT, new UUID(Convert.ToString(reader["undershirt_item"])), new UUID(Convert.ToString(reader["undershirt_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.UNDERPANTS, new UUID(Convert.ToString(reader["underpants_item"])), new UUID(Convert.ToString(reader["underpants_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.SKIRT, new UUID(Convert.ToString(reader["skirt_item"])), new UUID(Convert.ToString(reader["skirt_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.ALPHA, new UUID(Convert.ToString(reader["alpha_item"])), new UUID(Convert.ToString(reader["alpha_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.TATTOO, new UUID(Convert.ToString(reader["tattoo_item"])), new UUID(Convert.ToString(reader["tattoo_asset"])))); appearance.SetWearable( new AvatarWearable( AvatarWearable.PHYSICS, new UUID(Convert.ToString(reader["physics_item"])), new UUID(Convert.ToString(reader["physics_asset"])))); } return appearance; }
/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args, IScene scene) { if (m_log.IsDebugEnabled) { m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); } if (args.ContainsKey("region_id")) { UUID.TryParse(args ["region_id"].AsString(), out RegionID); } if (args ["circuit_code"] != null) { UInt32.TryParse((string)args ["circuit_code"].AsString(), out CircuitCode); } if (args ["agent_uuid"] != null) { AgentID = args ["agent_uuid"].AsUUID(); } if (args ["session_uuid"] != null) { SessionID = args ["session_uuid"].AsUUID(); } if (args ["position"] != null) { Vector3.TryParse(args ["position"].AsString(), out Position); } if (args ["velocity"] != null) { Vector3.TryParse(args ["velocity"].AsString(), out Velocity); } if (args ["center"] != null) { Vector3.TryParse(args ["center"].AsString(), out Center); } if (args ["size"] != null) { Vector3.TryParse(args ["size"].AsString(), out Size); } if (args ["at_axis"] != null) { Vector3.TryParse(args ["at_axis"].AsString(), out AtAxis); } if (args ["left_axis"] != null) { Vector3.TryParse(args ["left_axis"].AsString(), out AtAxis); } if (args ["up_axis"] != null) { Vector3.TryParse(args ["up_axis"].AsString(), out AtAxis); } if (args.ContainsKey("wait_for_root") && args ["wait_for_root"] != null) { SenderWantsToWaitForRoot = args ["wait_for_root"].AsBoolean(); } if (args ["far"] != null) { Far = (float)(args ["far"].AsReal()); } if (args ["aspect"] != null) { Aspect = (float)args ["aspect"].AsReal(); } if (args ["throttles"] != null) { Throttles = args ["throttles"].AsBinary(); } if (args ["locomotion_state"] != null) { UInt32.TryParse(args ["locomotion_state"].AsString(), out LocomotionState); } if (args ["head_rotation"] != null) { Quaternion.TryParse(args ["head_rotation"].AsString(), out HeadRotation); } if (args ["body_rotation"] != null) { Quaternion.TryParse(args ["body_rotation"].AsString(), out BodyRotation); } if (args ["control_flags"] != null) { UInt32.TryParse(args ["control_flags"].AsString(), out ControlFlags); } if (args ["energy_level"] != null) { EnergyLevel = (float)(args ["energy_level"].AsReal()); } if (args ["god_level"] != null) { Byte.TryParse(args ["god_level"].AsString(), out GodLevel); } if (args ["always_run"] != null) { AlwaysRun = args ["always_run"].AsBoolean(); } if (args ["prey_agent"] != null) { PreyAgent = args ["prey_agent"].AsUUID(); } if (args ["agent_access"] != null) { Byte.TryParse(args ["agent_access"].AsString(), out AgentAccess); } if (args ["active_group_id"] != null) { ActiveGroupID = args ["active_group_id"].AsUUID(); } if ((args ["groups"] != null) && (args ["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args ["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups [i++] = new AgentGroupData((OSDMap)o); } } } if ((args ["animations"] != null) && (args ["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args ["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims [i++] = new Animation((OSDMap)o); } } } if (args ["default_animation"] != null) { try { DefaultAnim = new Animation((OSDMap)args ["default_animation"]); } catch { DefaultAnim = null; } } if (args ["animation_state"] != null) { try { AnimState = new Animation((OSDMap)args ["animation_state"]); } catch { AnimState = null; } } //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); // AgentTextures = new UUID[textures.Count]; // int i = 0; // foreach (OSD o in textures) // AgentTextures[i++] = o.AsUUID(); //} Appearance = new AvatarAppearance(); // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args ["texture_entry"] != null) { byte[] rawtextures = args ["texture_entry"].AsBinary(); Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length); Appearance.SetTextureEntries(textures); } if (args ["visual_params"] != null) { Appearance.SetVisualParams(args ["visual_params"].AsBinary()); } if ((args ["wearables"] != null) && (args ["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args ["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears [i]); Appearance.SetWearable(i, awear); } } if ((args ["attachments"] != null) && (args ["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args ["attachments"]); foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } } // end of code to remove if (args.ContainsKey("packed_appearance") && (args ["packed_appearance"]).Type == OSDType.Map) { Appearance = new AvatarAppearance((OSDMap)args ["packed_appearance"]); } else { m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); } if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) { CallbackURI = args["callback_uri"].AsString(); } // Attachment objects if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) { OSDArray attObjs = (OSDArray)(args["attach_objects"]); AttachmentObjects = new List <ISceneObject>(); AttachmentObjectStates = new List <string>(); foreach (OSD o in attObjs) { if (o.Type == OSDType.Map) { OSDMap info = (OSDMap)o; ISceneObject so = scene.DeserializeObject(info["sog"].AsString()); so.ExtraFromXmlString(info["extra"].AsString()); so.HasGroupChanged = info["modified"].AsBoolean(); AttachmentObjects.Add(so); AttachmentObjectStates.Add(info["state"].AsString()); } } } }