Merge commit '460946ad62b682c7a942751f192ca9e96b662f0e' into bigmerge

Conflicts:
	OpenSim/Region/Framework/Scenes/Scene.cs
	OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
avinationmerge
Melanie 2011-10-11 23:32:16 +01:00
commit a9af618842
6 changed files with 85 additions and 134 deletions

View File

@ -153,7 +153,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (sp.PresenceType == PresenceType.Npc) if (sp.PresenceType == PresenceType.Npc)
RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null);
else else
RezSingleAttachmentFromInventory(sp.ControllingClient, attach.ItemID, p); RezSingleAttachmentFromInventory(sp, attach.ItemID, p);
} }
catch (Exception e) catch (Exception e)
{ {
@ -205,7 +205,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <param name="objectLocalID"></param> /// <param name="objectLocalID"></param>
/// <param name="AttachmentPt"></param> /// <param name="AttachmentPt"></param>
/// <param name="silent"></param> /// <param name="silent"></param>
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) private void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", // "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})",
@ -267,24 +267,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
} }
public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
{
if (!Enabled)
return false;
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
if (sp == null)
{
m_log.ErrorFormat(
"[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId);
return false;
}
return AttachObject(sp, group, AttachmentPt, silent);
}
private bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
{ {
lock (sp.AttachmentsSyncLock) lock (sp.AttachmentsSyncLock)
{ {
@ -366,27 +349,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return true; return true;
} }
public void RezMultipleAttachmentsFromInventory( private void RezMultipleAttachmentsFromInventory(IClientAPI remoteClient, List<KeyValuePair<UUID, uint>> rezlist)
IClientAPI remoteClient,
List<KeyValuePair<UUID, uint>> rezlist)
{ {
if (!Enabled) if (!Enabled)
return; return;
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); ScenePresence sp;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out sp))
if (sp == null) RezMultipleAttachmentsFromInventory(sp, rezlist);
{ else
m_log.ErrorFormat( m_log.ErrorFormat(
"[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezMultipleAttachmentsFromInventory()", "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezMultipleAttachmentsFromInventory()",
remoteClient.Name, remoteClient.AgentId); remoteClient.Name, remoteClient.AgentId);
return; return;
} }
public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
{
if (!Enabled)
return;
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name);
lock (sp.AttachmentsSyncLock) lock (sp.AttachmentsSyncLock)
{ {
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name);
foreach (KeyValuePair<UUID, uint> rez in rezlist) foreach (KeyValuePair<UUID, uint> rez in rezlist)
{ {
RezSingleAttachmentFromInventory(sp, rez.Key, rez.Value); RezSingleAttachmentFromInventory(sp, rez.Key, rez.Value);
@ -394,7 +379,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
} }
public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) private ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{ {
return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null); return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null);
} }
@ -418,7 +403,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt); return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt);
} }
public ISceneEntity RezSingleAttachmentFromInventory(ScenePresence sp, UUID itemID, uint AttachmentPt) public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
{ {
if (!Enabled) if (!Enabled)
return null; return null;
@ -630,21 +615,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
} }
public void DetachSingleAttachmentToGround(uint soLocalId, IClientAPI remoteClient) private void DetachSingleAttachmentToGround(uint soLocalId, IClientAPI remoteClient)
{
if (!Enabled)
return;
ScenePresence sp;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out sp))
DetachSingleAttachmentToGround(sp, soLocalId);
}
public void DetachSingleAttachmentToGround(IScenePresence sp, uint soLocalId)
{ {
if (!Enabled) if (!Enabled)
return; return;
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", // "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
// remoteClient.Name, soLocalId); // sp.UUID, soLocalId);
SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId); SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId);
if (so == null) if (so == null)
return; return;
if (so.AttachedAvatar != remoteClient.AgentId) if (so.AttachedAvatar != sp.UUID)
return; return;
UUID inventoryID = so.GetFromItemID(); UUID inventoryID = so.GetFromItemID();
@ -653,57 +648,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", // "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
// so.Name, so.LocalId, inventoryID); // so.Name, so.LocalId, inventoryID);
ScenePresence presence; lock (sp.AttachmentsSyncLock)
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{ {
lock (presence.AttachmentsSyncLock) if (!m_scene.Permissions.CanRezObject(
{ so.PrimCount, sp.UUID, sp.AbsolutePosition))
if (!m_scene.Permissions.CanRezObject( return;
so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
return;
bool changed = presence.Appearance.DetachAttachment(inventoryID); bool changed = sp.Appearance.DetachAttachment(inventoryID);
if (changed && m_scene.AvatarFactory != null) if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
presence.RemoveAttachment(so); sp.RemoveAttachment(so);
DetachSceneObjectToGround(so, presence);
List<UUID> uuids = new List<UUID>(); SceneObjectPart rootPart = so.RootPart;
uuids.Add(inventoryID); rootPart.FromItemID = UUID.Zero;
m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); so.AbsolutePosition = sp.AbsolutePosition;
remoteClient.SendRemoveInventoryItem(inventoryID); so.AttachedAvatar = UUID.Zero;
} rootPart.SetParentLocalId(0);
so.ClearPartAttachmentData();
rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
so.HasGroupChanged = true;
rootPart.Rezzed = DateTime.Now;
rootPart.RemFlag(PrimFlags.TemporaryOnRez);
so.AttachToBackup();
m_scene.EventManager.TriggerParcelPrimCountTainted();
rootPart.ScheduleFullUpdate();
rootPart.ClearUndoState();
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero); List<UUID> uuids = new List<UUID>();
uuids.Add(inventoryID);
m_scene.InventoryService.DeleteItems(sp.UUID, uuids);
sp.ControllingClient.SendRemoveInventoryItem(inventoryID);
} }
}
/// <summary> m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero);
/// Detach the given scene object to the ground.
/// </summary>
/// <remarks>
/// The caller has to take care of all the other work in updating avatar appearance, inventory, etc.
/// </remarks>
/// <param name="so">The scene object to detach.</param>
/// <param name="sp">The scene presence from which the scene object is being detached.</param>
private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp)
{
SceneObjectPart rootPart = so.RootPart;
rootPart.FromItemID = UUID.Zero;
so.AbsolutePosition = sp.AbsolutePosition;
so.AttachedAvatar = UUID.Zero;
rootPart.SetParentLocalId(0);
so.ClearPartAttachmentData();
rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
so.HasGroupChanged = true;
rootPart.Rezzed = DateTime.Now;
rootPart.RemFlag(PrimFlags.TemporaryOnRez);
so.AttachToBackup();
m_scene.EventManager.TriggerParcelPrimCountTainted();
rootPart.ScheduleFullUpdate();
rootPart.ClearUndoState();
} }
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.

View File

@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup;
m_attMod.AttachObject(m_presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false);
// Check status on scene presence // Check status on scene presence
Assert.That(m_presence.HasAttachments(), Is.True); Assert.That(m_presence.HasAttachments(), Is.True);
@ -140,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
m_attMod.RezSingleAttachmentFromInventory( m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); m_presence, attItemId, (uint)AttachmentPoint.Chest);
// Check scene presence status // Check scene presence status
Assert.That(m_presence.HasAttachments(), Is.True); Assert.That(m_presence.HasAttachments(), Is.True);
@ -174,8 +174,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); m_presence, attItemId, (uint)AttachmentPoint.Chest);
m_attMod.DetachSingleAttachmentToGround(so.LocalId, m_presence.ControllingClient); m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId);
// Check scene presence status // Check scene presence status
Assert.That(m_presence.HasAttachments(), Is.False); Assert.That(m_presence.HasAttachments(), Is.False);
@ -208,7 +208,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
m_attMod.RezSingleAttachmentFromInventory( m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); m_presence, attItemId, (uint)AttachmentPoint.Chest);
m_attMod.DetachSingleAttachmentToInv(attItemId, m_presence.ControllingClient); m_attMod.DetachSingleAttachmentToInv(attItemId, m_presence.ControllingClient);
// Check status on scene presence // Check status on scene presence

View File

@ -58,17 +58,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="silent"></param> /// <param name="silent"></param>
void DeleteAttachmentsFromScene(IScenePresence sp, bool silent); void DeleteAttachmentsFromScene(IScenePresence sp, bool silent);
/// <summary>
/// Attach an object to an avatar from the world.
/// </summary>
/// <param name="controllingClient"></param>
/// <param name="localID"></param>
/// <param name="attachPoint"></param>
/// <param name="rot"></param>
/// <param name="silent"></param>
void AttachObject(
IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent);
/// <summary> /// <summary>
/// Attach an object to an avatar /// Attach an object to an avatar
/// </summary> /// </summary>
@ -77,17 +66,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="AttachmentPt"></param> /// <param name="AttachmentPt"></param>
/// <param name="silent"></param> /// <param name="silent"></param>
/// <returns>true if the object was successfully attached, false otherwise</returns> /// <returns>true if the object was successfully attached, false otherwise</returns>
bool AttachObject( bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent);
IClientAPI remoteClient, SceneObjectGroup grp, uint AttachmentPt, bool silent);
/// <summary>
/// Rez an attachment from user inventory and change inventory status to match.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
/// <param name="AttachmentPt"></param>
/// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
/// <summary> /// <summary>
/// Rez an attachment from user inventory and change inventory status to match. /// Rez an attachment from user inventory and change inventory status to match.
@ -96,7 +75,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="itemID"></param> /// <param name="itemID"></param>
/// <param name="AttachmentPt"></param> /// <param name="AttachmentPt"></param>
/// <returns>The scene object that was attached. Null if the scene object could not be found</returns> /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
ISceneEntity RezSingleAttachmentFromInventory(ScenePresence sp, UUID itemID, uint AttachmentPt); ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt);
// Same as above, but also load script states from a separate doc // Same as above, but also load script states from a separate doc
ISceneEntity RezSingleAttachmentFromInventory( ISceneEntity RezSingleAttachmentFromInventory(
@ -105,12 +84,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// <summary> /// <summary>
/// Rez multiple attachments from a user's inventory /// Rez multiple attachments from a user's inventory
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="sp"></param>
/// <param name="header"></param> /// <param name="header"></param>
/// <param name="objects"></param> /// <param name="objects"></param>
void RezMultipleAttachmentsFromInventory( void RezMultipleAttachmentsFromInventory(IScenePresence sp,List<KeyValuePair<UUID, uint>> rezlist);
IClientAPI remoteClient,
List<KeyValuePair<UUID, uint>> rezlist);
/// <summary> /// <summary>
/// Detach an object from the avatar. /// Detach an object from the avatar.
@ -126,9 +103,9 @@ namespace OpenSim.Region.Framework.Interfaces
/// <summary> /// <summary>
/// Detach the given item to the ground. /// Detach the given item to the ground.
/// </summary> /// </summary>
/// <param name="sp"></param>
/// <param name="objectLocalID"></param> /// <param name="objectLocalID"></param>
/// <param name="remoteClient"></param> void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID);
void DetachSingleAttachmentToGround(uint objectLocalID, IClientAPI remoteClient);
/// <summary> /// <summary>
/// Detach the given item so that it remains in the user's inventory. /// Detach the given item so that it remains in the user's inventory.

View File

@ -2528,9 +2528,7 @@ namespace OpenSim.Region.Framework.Scenes
RootPrim.RemFlag(PrimFlags.TemporaryOnRez); RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
if (AttachmentsModule != null) if (AttachmentsModule != null)
AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); AttachmentsModule.AttachObject(sp, grp, 0, false);
m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
} }
else else
{ {

View File

@ -132,11 +132,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
UUID attAssetId = TestHelpers.ParseTail(0x3); UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att"; string attName = "att";
UserInventoryHelpers.CreateInventoryItem( UserInventoryHelpers.CreateInventoryItem(scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
am.RezSingleAttachmentFromInventory( am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
sp.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);

View File

@ -3265,10 +3265,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SceneObjectGroup grp = m_host.ParentGroup; SceneObjectGroup grp = m_host.ParentGroup;
ScenePresence presence = World.GetScenePresence(m_host.OwnerID); ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
if (presence.Scene.AttachmentsModule != null)
{ IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
presence.Scene.AttachmentsModule.AttachObject(presence.ControllingClient, grp, (uint)attachment, false); if (attachmentsModule != null)
} attachmentsModule.AttachObject(presence, grp, (uint)attachment, false);
} }
} }