/// <summary> /// Add an item to this prim's inventory. If an item with the same name already exists, it is replaced. /// </summary> /// <param name="item"></param> /// <param name="allowedDrop"></param> public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) { List<TaskInventoryItem> il = GetInventoryItems(); foreach (TaskInventoryItem i in il) { if (i.Name == item.Name) { if (i.InvType == (int) InventoryType.LSL) RemoveScriptInstance(i.ItemID, false); RemoveInventoryItem(i.ItemID); break; } } AddInventoryItem(item.Name, item, allowedDrop); }
/// <summary> /// Update an item in a prim (task) inventory. /// This method does not handle scripts, <see>RezScript(IClientAPI, UUID, unit)</see> /// </summary> /// <param name="remoteClient"></param> /// <param name="transactionID"></param> /// <param name="itemInfo"></param> /// <param name="primLocalID"></param> protected void UpdateTaskInventory(IClientAPI remoteClient, UUID transactionID, TaskInventoryItem itemInfo, uint primLocalID) { UUID itemID = itemInfo.ItemID; // Find the prim we're dealing with ISceneChildEntity part = m_scene.GetSceneObjectPart(primLocalID); if (part != null) { TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID); bool allowInventoryDrop = (part.GetEffectiveObjectFlags() & (uint) PrimFlags.AllowInventoryDrop) != 0; // Explicity allow anyone to add to the inventory if the // AllowInventoryDrop flag has been set. Don't however let // them update an item unless they pass the external checks // if (!m_scene.Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId) && (currentItem != null || !allowInventoryDrop)) return; if (currentItem == null) { UUID copyID = UUID.Random(); if (itemID != UUID.Zero) { InventoryItemBase item = m_scene.InventoryService.GetItem(remoteClient.AgentId, itemID); // If we've found the item in the user's inventory or in the library if (item != null) { part.ParentEntity.AddInventoryItem(remoteClient, primLocalID, item, copyID); MainConsole.Instance.InfoFormat( "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", item.Name, primLocalID, remoteClient.Name); part.GetProperties(remoteClient); if (!m_scene.Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint) PermissionMask.Copy) == 0) { List<UUID> uuids = new List<UUID> {itemID}; RemoveInventoryItem(remoteClient, uuids); } } } else { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!", itemID, remoteClient.Name); } } } else // Updating existing item with new perms etc { // Base ALWAYS has move currentItem.BasePermissions |= (uint) PermissionMask.Move; // Check if we're allowed to mess with permissions if (!m_scene.Permissions.IsGod(remoteClient.AgentId)) // Not a god { if (remoteClient.AgentId != part.OwnerID) // Not owner { // Friends and group members can't change any perms itemInfo.BasePermissions = currentItem.BasePermissions; itemInfo.EveryonePermissions = currentItem.EveryonePermissions; itemInfo.GroupPermissions = currentItem.GroupPermissions; itemInfo.NextPermissions = currentItem.NextPermissions; itemInfo.CurrentPermissions = currentItem.CurrentPermissions; } else { // Owner can't change base, and can change other // only up to base itemInfo.BasePermissions = currentItem.BasePermissions; itemInfo.EveryonePermissions &= currentItem.BasePermissions; itemInfo.GroupPermissions &= currentItem.BasePermissions; itemInfo.CurrentPermissions &= currentItem.BasePermissions; itemInfo.NextPermissions &= currentItem.BasePermissions; } } // Next ALWAYS has move itemInfo.NextPermissions |= (uint) PermissionMask.Move; if (part.Inventory.UpdateInventoryItem(itemInfo)) { part.GetProperties(remoteClient); } } } else { MainConsole.Instance.WarnFormat( "[PRIM INVENTORY]: " + "Update with item {0} requested of prim {1} for {2} but this prim does not exist", itemID, primLocalID, remoteClient.Name); } }
/// <summary> /// Rez a script into a prim's inventory from another prim /// This is used for the LSL function llRemoteLoadScriptPin and requires a valid pin to be used /// </summary> /// <param name="srcId">The UUID of the script that is going to be copied</param> /// <param name="srcPart">The prim that the script that is going to be copied from</param> /// <param name="destId">The UUID of the prim that the </param> /// <param name="pin">The ScriptAccessPin of the prim</param> /// <param name="running">Whether the script should be running when it is started</param> /// <param name="start_param">The start param to pass to the script</param> public void RezScript(UUID srcId, ISceneChildEntity srcPart, UUID destId, int pin, int running, int start_param) { TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId); if (srcTaskItem == null) { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: Tried to retrieve item ID {0} from prim {1}, {2} for rezzing a script but the " + " item does not exist in this inventory", srcId, srcPart.Name, srcPart.UUID); return; } ISceneChildEntity destPart = m_scene.GetSceneObjectPart(destId); if (destPart == null) { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: " + "Could not find script for ID {0}", destId); return; } // Must own the object, and have modify rights if (srcPart.OwnerID != destPart.OwnerID) { // Group permissions if ((destPart.GroupID == UUID.Zero) || (destPart.GroupID != srcPart.GroupID) || ((destPart.GroupMask & (uint) PermissionMask.Modify) == 0)) return; } else { if ((destPart.OwnerMask & (uint) PermissionMask.Modify) == 0) return; } if (destPart.ScriptAccessPin != pin) { MainConsole.Instance.WarnFormat( "[PRIM INVENTORY]: " + "Script in object {0} : {1}, attempted to load script {2} : {3} into object {4} : {5} with invalid pin {6}", srcPart.Name, srcId, srcTaskItem.Name, srcTaskItem.ItemID, destPart.Name, destId, pin); // the LSL Wiki says we are supposed to shout on the DEBUG_CHANNEL - // "Object: Task Object trying to illegally load script onto task Other_Object!" // How do we shout from in here? return; } TaskInventoryItem destTaskItem = new TaskInventoryItem { ItemID = UUID.Random(), CreatorID = srcTaskItem.CreatorID, CreatorData = srcTaskItem.CreatorData, AssetID = srcTaskItem.AssetID, GroupID = destPart.GroupID, OwnerID = destPart.OwnerID, ParentID = destPart.UUID, ParentPartID = destPart.UUID, BasePermissions = srcTaskItem.BasePermissions, EveryonePermissions = srcTaskItem.EveryonePermissions, GroupPermissions = srcTaskItem.GroupPermissions, CurrentPermissions = srcTaskItem.CurrentPermissions, NextPermissions = srcTaskItem.NextPermissions, Flags = srcTaskItem.Flags, SalePrice = srcTaskItem.SalePrice, SaleType = srcTaskItem.SaleType }; if (destPart.OwnerID != srcPart.OwnerID) { if (m_scene.Permissions.PropagatePermissions()) { destTaskItem.CurrentPermissions = srcTaskItem.CurrentPermissions & srcTaskItem.NextPermissions; destTaskItem.GroupPermissions = srcTaskItem.GroupPermissions & srcTaskItem.NextPermissions; destTaskItem.EveryonePermissions = srcTaskItem.EveryonePermissions & srcTaskItem.NextPermissions; destTaskItem.BasePermissions = srcTaskItem.BasePermissions & srcTaskItem.NextPermissions; destTaskItem.CurrentPermissions |= 16; // Slam! } } destTaskItem.Description = srcTaskItem.Description; destTaskItem.Name = srcTaskItem.Name; destTaskItem.InvType = srcTaskItem.InvType; destTaskItem.Type = srcTaskItem.Type; destPart.Inventory.AddInventoryItemExclusive(destTaskItem, false); if (running > 0) destPart.Inventory.CreateScriptInstance(destTaskItem, start_param, false, StateSource.NewRez); IScenePresence avatar; if (m_scene.TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) destPart.GetProperties(avatar.ControllingClient); }
private void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader) { item.PermsMask = reader.ReadElementContentAsInt("PermsMask", String.Empty); }
private void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader) { item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty); }
private void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader) { item.OwnerID = ReadUUID(reader, "OwnerID"); }
private void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader) { item.ParentPartID = ReadUUID(reader, "ParentPartID"); }
/// <summary> /// Rez an object into the scene from a prim's inventory. /// </summary> /// <param name="sourcePart"></param> /// <param name="item"></param> /// <param name="pos"></param> /// <param name="rot"></param> /// <param name="vel"></param> /// <param name="param"></param> /// <param name="RezzedFrom"></param> /// <param name="RezObjectAtRoot"></param> /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful</returns> public ISceneEntity RezObject( ISceneChildEntity sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion rot, Vector3 vel, int param, UUID RezzedFrom, bool RezObjectAtRoot) { if (item != null) { UUID ownerID = item.OwnerID; byte[] rezAsset = World.AssetService.GetData(item.AssetID.ToString()); if (rezAsset != null) { string xmlData = Utils.BytesToString(rezAsset); ISceneEntity group = SceneEntitySerializer.SceneObjectSerializer.FromOriginalXmlFormat(xmlData, World); if (group == null) return null; string reason; if (!World.Permissions.CanRezObject(group.ChildrenEntities().Count, ownerID, pos, out reason)) { World.GetScenePresence(ownerID) .ControllingClient.SendAlertMessage("You do not have permission to rez objects here: " + reason); return null; } List<ISceneChildEntity> partList = group.ChildrenEntities(); // we set it's position in world. // llRezObject sets the whole group at the position, while llRezAtRoot rezzes the group based on the root prim's position // See: http://lslwiki.net/lslwiki/wakka.php?wakka=llRezAtRoot // Shorthand: llRezAtRoot rezzes the root prim of the group at the position // llRezObject rezzes the center of group at the position if (RezObjectAtRoot) //This sets it right... group.AbsolutePosition = pos; else { // center is on average of all positions // less root prim position Vector3 offset = partList.Aggregate(Vector3.Zero, (current, child) => current + child.AbsolutePosition); offset /= partList.Count; offset -= group.AbsolutePosition; offset += pos; group.AbsolutePosition = offset; } ISceneChildEntity rootPart = group.GetChildPart(group.UUID); // Since renaming the item in the inventory does not affect the name stored // in the serialization, transfer the correct name from the inventory to the // object itself before we rez. rootPart.Name = item.Name; rootPart.Description = item.Description; group.SetGroup(sourcePart.GroupID, group.OwnerID, false); if (rootPart.OwnerID != item.OwnerID) { if (World.Permissions.PropagatePermissions()) { if ((item.CurrentPermissions & 8) != 0) { foreach (ISceneChildEntity part in partList) { part.EveryoneMask = item.EveryonePermissions; part.NextOwnerMask = item.NextPermissions; } } group.ApplyNextOwnerPermissions(); } } foreach (ISceneChildEntity part in partList) { if (part.OwnerID != item.OwnerID) { part.LastOwnerID = part.OwnerID; part.OwnerID = item.OwnerID; part.Inventory.ChangeInventoryOwner(item.OwnerID); } else if ((item.CurrentPermissions & 8) != 0) // Slam! { part.EveryoneMask = item.EveryonePermissions; part.NextOwnerMask = item.NextPermissions; } } rootPart.TrimPermissions(); if (group.RootChild.Shape.PCode == (byte) PCode.Prim) { group.ClearPartAttachmentData(); } group.UpdateGroupRotationR(rot); //group.ApplyPhysics(m_physicalPrim); World.SceneGraph.AddPrimToScene(group); if ((group.RootChild.Flags & PrimFlags.Physics) == PrimFlags.Physics) { group.RootChild.PhysActor.OnPhysicalRepresentationChanged += delegate { float groupmass = group.GetMass(); //Apply the velocity to the object //llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); // @Above: Err.... no. Read http://lslwiki.net/lslwiki/wakka.php?wakka=llRezObject // Notice the "Creates ("rezzes") object's inventory object centered at position pos (in region coordinates) with velocity vel" // This means SET the velocity to X, not just temperarily add it! // -- Revolution Smythe llSetForce( new LSL_Vector(vel* groupmass), 0); group.RootChild.PhysActor .ForceSetVelocity(vel* groupmass); group.RootChild.PhysActor .Velocity = vel* groupmass; }; } group.CreateScriptInstances(param, true, StateSource.ScriptedRez, RezzedFrom, false); if (!World.Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint) PermissionMask.Copy) == 0) sourcePart.Inventory.RemoveInventoryItem(item.ItemID); } group.ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate); return rootPart.ParentEntity; } } return null; }
private TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name) { TaskInventoryDictionary tinv = new TaskInventoryDictionary(); reader.ReadStartElement(name, String.Empty); if (reader.IsEmptyElement) { reader.Read(); return tinv; } while (reader.Name == "TaskInventoryItem") { reader.ReadStartElement("TaskInventoryItem", String.Empty); // TaskInventory TaskInventoryItem item = new TaskInventoryItem(); while (reader.NodeType != XmlNodeType.EndElement) { TaskInventoryXmlProcessor p = null; try { if (m_TaskInventoryXmlProcessors.TryGetValue(reader.Name, out p)) p(item, reader); else { //MainConsole.Instance.DebugFormat("[SceneObjectSerializer]: caught unknown element in TaskInventory {0}, {1}", reader.Name, reader.Value); reader.ReadOuterXml(); } } catch (Exception e) { MainConsole.Instance.DebugFormat( "[SceneObjectSerializer]: exception while parsing Inventory Items {0}: {1}", reader.Name, e); } } reader.ReadEndElement(); // TaskInventoryItem tinv.Add(item.ItemID, item); } if (reader.NodeType == XmlNodeType.EndElement) reader.ReadEndElement(); // TaskInventory return tinv; }
public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) { TaskInventoryItem it = GetInventoryItem(item.ItemID); if (it != null) { item.ParentID = m_part.UUID; item.ParentPartID = m_part.UUID; item.Flags = m_items[item.ItemID].Flags; // If group permissions have been set on, check that the groupID is up to date in case it has // changed since permissions were last set. if (item.GroupPermissions != (uint) PermissionMask.None) item.GroupID = m_part.GroupID; if (item.AssetID == UUID.Zero) item.AssetID = it.AssetID; lock (m_itemsLock) { m_items[item.ItemID] = item; m_inventorySerial++; } if (fireScriptEvents) m_part.TriggerScriptChangedEvent(Changed.INVENTORY); HasInventoryChanged = true; return true; } MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: " + "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", item.ItemID, m_part.Name, m_part.UUID, m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); return false; }
/// <summary> /// Start multiple scripts in the object /// </summary> /// <param name="part"></param> /// <param name="items"></param> /// <param name="startParam"></param> /// <param name="postOnRez"></param> /// <param name="stateSource"></param> /// <param name="rezzedFrom"></param> /// <param name="clearStateSaves"></param> public void rez_scripts(ISceneChildEntity part, TaskInventoryItem[] items, int startParam, bool postOnRez, StateSource stateSource, UUID rezzedFrom, bool clearStateSaves) { List<LUStruct> ItemsToStart = items.Select( item => m_scriptEngine.StartScript(part, item.ItemID, startParam, postOnRez, stateSource, rezzedFrom, clearStateSaves)) .Where(itemToQueue => itemToQueue.Action != LUType.Unknown) .ToList(); if (ItemsToStart.Count != 0) m_scriptEngine.MaintenanceThread.AddScriptChange(ItemsToStart.ToArray(), LoadPriority.FirstStart); }
/// <summary> /// Update an existing inventory item. /// </summary> /// <param name="item"> /// The updated item. An item with the same id must already exist /// in this prim's inventory. /// </param> /// <returns>false if the item did not exist, true if the update occurred successfully</returns> public bool UpdateInventoryItem(TaskInventoryItem item) { return UpdateInventoryItem(item, true); }
public ISceneEntity GetRezReadySceneObject(TaskInventoryItem item) { byte[] rezAsset = m_part.ParentGroup.Scene.AssetService.GetData(item.AssetID.ToString()); if (null == rezAsset) { MainConsole.Instance.WarnFormat( "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}", item.AssetID, item.Name, m_part.Name); return null; } string xmlData = Utils.BytesToString(rezAsset); ISceneEntity group = SceneEntitySerializer.SceneObjectSerializer.FromOriginalXmlFormat(xmlData, m_part.ParentGroup .Scene); if (group == null) return null; group.IsDeleted = false; foreach (ISceneChildEntity part in group.ChildrenEntities()) { part.IsLoading = false; } //Reset IDs, etc m_part.ParentGroup.Scene.SceneGraph.PrepPrimForAdditionToScene(group); ISceneChildEntity rootPart = group.GetChildPart(group.UUID); // Since renaming the item in the inventory does not affect the name stored // in the serialization, transfer the correct name from the inventory to the // object itself before we rez. rootPart.Name = item.Name; rootPart.Description = item.Description; List<ISceneChildEntity> partList = group.ChildrenEntities(); group.SetGroup(m_part.GroupID, group.OwnerID, false); if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) { if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) { foreach (ISceneChildEntity part in partList) { part.EveryoneMask = item.EveryonePermissions; part.NextOwnerMask = item.NextPermissions; } group.ApplyNextOwnerPermissions(); } } foreach (ISceneChildEntity part in partList) { if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) { part.LastOwnerID = part.OwnerID; part.OwnerID = item.OwnerID; part.Inventory.ChangeInventoryOwner(item.OwnerID); } part.EveryoneMask = item.EveryonePermissions; part.NextOwnerMask = item.NextPermissions; } rootPart.TrimPermissions(); return group; }
/// <summary> /// Start a script which is in this prim's inventory. /// </summary> /// <param name="item"></param> /// <param name="startParam"></param> /// <param name="postOnRez"></param> /// <param name="stateSource"></param> /// <returns></returns> public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, StateSource stateSource) { // MainConsole.Instance.InfoFormat( // "[PRIM INVENTORY]: " + // "Starting script {0}, {1} in prim {2}, {3}", // item.Name, item.ItemID, Name, UUID); if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) return; if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) { lock (m_itemsLock) { m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; } bool SendUpdate = m_part.AddFlag(PrimFlags.Scripted); m_part.ParentGroup.Scene.EventManager.TriggerRezScripts( m_part, new[] {item}, startParam, postOnRez, stateSource, UUID.Zero, false); if (SendUpdate) m_part.ScheduleUpdate(PrimUpdateFlags.PrimFlags); //We only need to send a compressed } HasInventoryChanged = true; ResumeScript(item); }
private void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) { //Disable this, if we are rezzing from inventory, we want to get a new ItemID for next time //item.OldItemID = ReadUUID (reader, "OldItemID"); ReadUUID(reader, "OldItemID"); }
private void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader) { item.AssetID = ReadUUID(reader, "AssetID"); }
private void ProcessTIName(TaskInventoryItem item, XmlTextReader reader) { item.Name = reader.ReadElementContentAsString("Name", String.Empty); }
private void ProcessTICreationDate(TaskInventoryItem item, XmlTextReader reader) { item.CreationDate = uint.Parse(reader.ReadElementContentAsString("CreationDate", String.Empty)); }
private void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader) { item.CurrentPermissions = uint.Parse(reader.ReadElementContentAsString("CurrentPermissions", String.Empty)); }
private void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader) { item.CreatorID = ReadUUID(reader, "CreatorID"); }
private void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader) { item.PermsGranter = ReadUUID(reader, "PermsGranter"); }
private void ProcessTICreatorData(TaskInventoryItem item, XmlTextReader reader) { item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty); }
private void ProcessTIType(TaskInventoryItem item, XmlTextReader reader) { item.Type = reader.ReadElementContentAsInt("Type", String.Empty); }
private void ProcessTIDescription(TaskInventoryItem item, XmlTextReader reader) { item.Description = reader.ReadElementContentAsString("Description", String.Empty); }
/// <summary> /// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory /// </summary> /// <param name="remoteClient"></param> /// <param name="transactionID"></param> /// <param name="localID"></param> /// <param name="itemBase"></param> protected void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID) { UUID itemID = itemBase.ID; UUID copyID = UUID.Random(); if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory { //Might be a library item, use UUID.Zero InventoryItemBase item = m_scene.InventoryService.GetItem(UUID.Zero, itemID); if (item != null) { ISceneChildEntity part = m_scene.GetSceneObjectPart(localID); if (part != null) { if (!m_scene.Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) return; part.ParentEntity.AddInventoryItem(remoteClient, localID, item, copyID); part.Inventory.CreateScriptInstance(copyID, 0, false, 0); // MainConsole.Instance.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); part.GetProperties(remoteClient); } else { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: " + "Could not rez script {0} into prim local ID {1} for user {2}" + " because the prim could not be found in the region!", item.Name, localID, remoteClient.Name); } } else { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", itemID, remoteClient.Name); } } else // script has been rezzed directly into a prim's inventory { ISceneChildEntity part = m_scene.GetSceneObjectPart(itemBase.Folder); if (part == null) return; if (!m_scene.Permissions.CanCreateObjectInventory( itemBase.InvType, part.UUID, remoteClient.AgentId)) return; AssetBase asset = new AssetBase(UUID.Random(), itemBase.Name, (AssetType) itemBase.AssetType, remoteClient.AgentId) { Description = itemBase.Description, Data = Encoding.ASCII.GetBytes(DefaultLSLScript) }; asset.ID = m_scene.AssetService.Store(asset); TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(itemBase.Folder); taskItem.ParentID = itemBase.Folder; taskItem.CreationDate = (uint) itemBase.CreationDate; taskItem.Name = itemBase.Name; taskItem.Description = itemBase.Description; taskItem.Type = itemBase.AssetType; taskItem.InvType = itemBase.InvType; taskItem.OwnerID = itemBase.Owner; taskItem.CreatorID = itemBase.CreatorIdAsUuid; taskItem.CreatorData = itemBase.CreatorData; taskItem.BasePermissions = itemBase.BasePermissions; taskItem.CurrentPermissions = itemBase.CurrentPermissions; taskItem.EveryonePermissions = itemBase.EveryOnePermissions; taskItem.GroupPermissions = itemBase.GroupPermissions; taskItem.NextPermissions = itemBase.NextPermissions; taskItem.GroupID = itemBase.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = itemBase.Flags; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.ID; taskItem.SalePrice = itemBase.SalePrice; taskItem.SaleType = itemBase.SaleType; part.Inventory.AddInventoryItem(taskItem, false); part.GetProperties(remoteClient); part.Inventory.CreateScriptInstance(taskItem, 0, false, StateSource.NewRez); } }
private void ProcessTIFlags(TaskInventoryItem item, XmlTextReader reader) { item.Flags = uint.Parse(reader.ReadElementContentAsString("Flags", String.Empty)); }
/// <summary> /// Copy a task (prim) inventory item to another task (prim) /// </summary> /// <param name="destId"></param> /// <param name="part"></param> /// <param name="itemId"></param> public void MoveTaskInventoryItemToObject(UUID destId, ISceneChildEntity part, UUID itemId) { TaskInventoryItem srcTaskItem = part.Inventory.GetInventoryItem(itemId); if (srcTaskItem == null) { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: Tried to retrieve item ID {0} from prim {1}, {2} for moving" + " but the item does not exist in this inventory", itemId, part.Name, part.UUID); return; } ISceneChildEntity destPart = m_scene.GetSceneObjectPart(destId); if (destPart == null) { MainConsole.Instance.ErrorFormat( "[PRIM INVENTORY]: " + "Could not find prim for ID {0}", destId); return; } // Can't transfer this // if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint) PermissionMask.Transfer) == 0)) return; if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint) PrimFlags.AllowInventoryDrop) == 0) { // object cannot copy items to an object owned by a different owner // unless llAllowInventoryDrop has been called return; } // must have both move and modify permission to put an item in an object if ((part.OwnerMask & ((uint) PermissionMask.Move | (uint) PermissionMask.Modify)) == 0) { return; } TaskInventoryItem destTaskItem = new TaskInventoryItem { ItemID = UUID.Random(), CreatorID = srcTaskItem.CreatorID, CreatorData = srcTaskItem.CreatorData, AssetID = srcTaskItem.AssetID, GroupID = destPart.GroupID, OwnerID = destPart.OwnerID, ParentID = destPart.UUID, ParentPartID = destPart.UUID, BasePermissions = srcTaskItem.BasePermissions, EveryonePermissions = srcTaskItem.EveryonePermissions, GroupPermissions = srcTaskItem.GroupPermissions, CurrentPermissions = srcTaskItem.CurrentPermissions, NextPermissions = srcTaskItem.NextPermissions, Flags = srcTaskItem.Flags, SalePrice = srcTaskItem.SalePrice, SaleType = srcTaskItem.SaleType }; if (destPart.OwnerID != part.OwnerID) { if (m_scene.Permissions.PropagatePermissions()) { destTaskItem.CurrentPermissions = srcTaskItem.CurrentPermissions & (srcTaskItem.NextPermissions | (uint) PermissionMask.Move); destTaskItem.GroupPermissions = srcTaskItem.GroupPermissions & (srcTaskItem.NextPermissions | (uint) PermissionMask.Move); destTaskItem.EveryonePermissions = srcTaskItem.EveryonePermissions & (srcTaskItem.NextPermissions | (uint) PermissionMask.Move); destTaskItem.BasePermissions = srcTaskItem.BasePermissions & (srcTaskItem.NextPermissions | (uint) PermissionMask.Move); destTaskItem.CurrentPermissions |= 16; // Slam! } } destTaskItem.Description = srcTaskItem.Description; destTaskItem.Name = srcTaskItem.Name; destTaskItem.InvType = srcTaskItem.InvType; destTaskItem.Type = srcTaskItem.Type; destPart.Inventory.AddInventoryItem(destTaskItem, part.OwnerID != destPart.OwnerID); if ((srcTaskItem.CurrentPermissions & (uint) PermissionMask.Copy) == 0) part.Inventory.RemoveInventoryItem(itemId); IScenePresence avatar; if (m_scene.TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) destPart.GetProperties(avatar.ControllingClient); }
private void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader) { item.GroupID = ReadUUID(reader, "GroupID"); }
// This needs ThreatLevel high. It is an excellent griefer tool, // In a loop, it can cause asset bloat and DOS levels of asset // writes. // public void osMakeNotecard(string notecardName, LSL_List contents) { if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osMakeNotecard", m_host, "OSSL", m_itemID)) return; // Create new asset AssetBase asset = new AssetBase(UUID.Random(), notecardName, AssetType.Notecard, m_host.OwnerID) { Description = "Script Generated Notecard" }; string notecardData = String.Empty; for (int i = 0; i < contents.Length; i++) { notecardData += contents.GetLSLStringItem(i) + "\n"; } int textLength = notecardData.Length; notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + textLength.ToString(CultureInfo.InvariantCulture) + "\n" + notecardData + "}\n"; asset.Data = Util.UTF8.GetBytes(notecardData); asset.ID = World.AssetService.Store(asset); // Create Task Entry TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(m_host.UUID); taskItem.ParentID = m_host.UUID; taskItem.CreationDate = (uint) Util.UnixTimeSinceEpoch(); taskItem.Name = asset.Name; taskItem.Description = asset.Description; taskItem.Type = (int) AssetType.Notecard; taskItem.InvType = (int) InventoryType.Notecard; taskItem.OwnerID = m_host.OwnerID; taskItem.CreatorID = m_host.OwnerID; taskItem.BasePermissions = (uint) PermissionMask.All; taskItem.CurrentPermissions = (uint) PermissionMask.All; taskItem.EveryonePermissions = 0; taskItem.NextPermissions = (uint) PermissionMask.All; taskItem.GroupID = m_host.GroupID; taskItem.GroupPermissions = 0; taskItem.Flags = 0; taskItem.SalePrice = 0; taskItem.SaleType = 0; taskItem.PermsGranter = UUID.Zero; taskItem.PermsMask = 0; taskItem.AssetID = asset.ID; m_host.Inventory.AddInventoryItem(taskItem, false); }
/// <summary> /// Add an item to this prim's inventory. If an item with the same name already exists, then an alternative /// name is chosen. /// </summary> /// <param name="item"></param> /// <param name="allowedDrop"></param> public void AddInventoryItem(TaskInventoryItem item, bool allowedDrop) { AddInventoryItem(item.Name, item, allowedDrop); }