mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
add llGetStartString and limited llRezObjectWithParams for testing
This commit is contained in:
@@ -253,6 +253,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, out Vector3 bbox, out float offsetHeight);
|
||||
bool GetRezReadySceneObjects(TaskInventoryItem item, UUID newOwner, UUID NewGroup, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, out Vector3 bbox, out float offsetHeight);
|
||||
|
||||
SceneObjectGroup GetSingleRezReadySceneObject(TaskInventoryItem item, UUID NewOwner, UUID NewGroup);
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing inventory item.
|
||||
/// </summary>
|
||||
|
||||
@@ -2590,6 +2590,31 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return true;
|
||||
}
|
||||
|
||||
public SceneObjectGroup GetSingleObjectToRez(byte[] assetData)
|
||||
{
|
||||
string xmlData = string.Empty;
|
||||
try
|
||||
{
|
||||
xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(assetData));
|
||||
using XmlTextReader wrappedReader = new(xmlData, XmlNodeType.Element, null);
|
||||
using XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings);
|
||||
reader.Read();
|
||||
|
||||
if (!"CoalescedObject".Equals(reader.Name))
|
||||
{
|
||||
SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(reader);
|
||||
return g;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[AGENT INVENTORY]: single object xml deserialization failed" + e.Message);
|
||||
Util.LogFailedXML("[AGENT INVENTORY]:", xmlData);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler Rez an object into a scene
|
||||
/// Calls the non-void event handler
|
||||
@@ -2813,6 +2838,65 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return objlist;
|
||||
}
|
||||
|
||||
public SceneObjectGroup ScriptRezObject(SceneObjectPart sourcePart, TaskInventoryItem item,
|
||||
UUID newSOGID,
|
||||
Vector3 pos, Quaternion? rot, Vector3 vel, int param, bool atRoot)
|
||||
{
|
||||
if (item is null)
|
||||
return null;
|
||||
|
||||
if(TryGetSceneObjectGroup(newSOGID, out _))
|
||||
return null;
|
||||
|
||||
SceneObjectGroup sog = sourcePart.Inventory.GetSingleRezReadySceneObject(item, sourcePart.OwnerID, sourcePart.GroupID);
|
||||
if(sog is null)
|
||||
return null;
|
||||
|
||||
int totalPrims = sog.PrimCount;
|
||||
|
||||
if (!Permissions.CanRezObject(totalPrims, sourcePart.OwnerID, pos))
|
||||
return null;
|
||||
|
||||
if (!Permissions.BypassPermissions())
|
||||
{
|
||||
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
|
||||
sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
|
||||
}
|
||||
|
||||
// position adjust
|
||||
if (totalPrims > 1) // nothing to do on a single prim
|
||||
{
|
||||
// current object position is root position
|
||||
if(!atRoot)
|
||||
{
|
||||
Quaternion orot = rot ?? sog.RootPart.GetWorldRotation();
|
||||
// possible should be bbox, but geometric center looks better
|
||||
Vector3 off = sog.GetGeometricCenter();
|
||||
off *= orot;
|
||||
pos -= off;
|
||||
}
|
||||
}
|
||||
|
||||
if (sog.IsAttachment == false && sog.RootPart.Shape.State != 0)
|
||||
{
|
||||
sog.RootPart.AttachedPos = sog.AbsolutePosition;
|
||||
sog.RootPart.Shape.LastAttachPoint = (byte)sog.AttachmentPoint;
|
||||
}
|
||||
|
||||
sog.RezzerID = sourcePart.UUID;
|
||||
|
||||
AddNewSceneObject(sog, true, pos, rot, vel);
|
||||
|
||||
// We can only call this after adding the scene object, since the scene object references the scene
|
||||
// to find out if scripts should be activated at all.
|
||||
sog.InvalidateEffectivePerms();
|
||||
sog.CreateScriptInstances(param, true, DefaultScriptEngine, 3);
|
||||
|
||||
sog.ScheduleGroupForUpdate(PrimUpdateFlags.FullUpdatewithAnimMatOvr);
|
||||
|
||||
return sog;
|
||||
}
|
||||
|
||||
public virtual bool returnObjects(SceneObjectGroup[] returnobjects,
|
||||
IClientAPI client)
|
||||
{
|
||||
|
||||
@@ -444,6 +444,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
public bool m_dupeInProgress = false;
|
||||
internal Dictionary<UUID, string> m_savedScriptState;
|
||||
|
||||
public string RezStringParameter = null;
|
||||
public UUID MonitoringObject { get; set; }
|
||||
|
||||
#region Properties
|
||||
|
||||
@@ -1218,6 +1218,72 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return true;
|
||||
}
|
||||
|
||||
public SceneObjectGroup GetSingleRezReadySceneObject(TaskInventoryItem item, UUID NewOwner, UUID NewGroup)
|
||||
{
|
||||
AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
|
||||
if (rezAsset is null)
|
||||
{
|
||||
m_log.Warn($"[PRIM INVENTORY]: Could not find asset {item.AssetID} for inventory item {item.Name} in {m_part.Name}");
|
||||
return null;
|
||||
}
|
||||
|
||||
SceneObjectGroup group = m_part.ParentGroup.Scene.GetSingleObjectToRez(rezAsset.Data);
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
group.ResetIDs();
|
||||
|
||||
SceneObjectPart rootPart = group.RootPart;
|
||||
|
||||
rootPart.Name = item.Name;
|
||||
rootPart.Description = item.Description;
|
||||
|
||||
group.SetGroup(NewGroup, null);
|
||||
SceneObjectPart[] partList = group.Parts;
|
||||
|
||||
bool slamThings = (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0;
|
||||
if (slamThings || rootPart.OwnerID.NotEqual(NewOwner))
|
||||
{
|
||||
if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
|
||||
{
|
||||
foreach (SceneObjectPart part in partList)
|
||||
{
|
||||
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
|
||||
part.EveryoneMask = item.EveryonePermissions;
|
||||
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
|
||||
part.NextOwnerMask = item.NextPermissions;
|
||||
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
|
||||
part.GroupMask = item.GroupPermissions;
|
||||
}
|
||||
|
||||
group.ApplyNextOwnerPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SceneObjectPart part in partList)
|
||||
{
|
||||
if (part.OwnerID.NotEqual(NewOwner))
|
||||
{
|
||||
if(part.GroupID.NotEqual(part.OwnerID))
|
||||
part.LastOwnerID = part.OwnerID;
|
||||
part.OwnerID = NewOwner;
|
||||
part.Inventory.ChangeInventoryOwner(NewOwner);
|
||||
}
|
||||
|
||||
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
|
||||
part.EveryoneMask = item.EveryonePermissions;
|
||||
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
|
||||
part.NextOwnerMask = item.NextPermissions;
|
||||
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
|
||||
part.GroupMask = item.GroupPermissions;
|
||||
}
|
||||
|
||||
rootPart.TrimPermissions();
|
||||
group.InvalidateDeepEffectivePerms();
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing inventory item.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user